Inspiration

3 views
Skip to first unread message

M@

unread,
Sep 6, 2010, 3:55:22 AM9/6/10
to tinspire
Got a fun program here to share.
I created this to produce a Sierpinski Fractal using the chaos game.

Type this into a program with variable 'a'.
It stores the randomly calculated points under lists x and y using the
inputed number of points.

---
'Define sierpinski(a)
'Prgm

Define x=mat►list(newMat(1,a))
Define y=mat►list(newMat(1,a))
Local prex
Local prey
Local r
prex:=int(rand()*100)
prey:=int(rand()*100)
For n,1,a
r:=int(rand()*3+1)
If r=1 Then
x[n]:= prex/2.
y[n]:= prey/2.
ElseIf r=2 Then
x[n]:=(prex+100)/2.
y[n]:=prey/2.
Else
x[n]:=(prex+50)/2.
y[n]:=(prey+50√3)/2.
EndIf
prex:=x[n]
prey:=y[n]
EndFor

'EndPrgm
---

Run the program with the number of points as 'a'. For example type
sierpinski(3000)
for 3000 point fractal.
Then set up a Graphs page as Scatter Plot under Graph Type with Window
Settings of x and y from 0 (min) to 100 (max).
Graph lists x and y under x and y respectively.

For more info on the Sierpinski Triangle and its chaos game see
http://en.wikipedia.org/wiki/Sierpinski_triangle



John Hanna

unread,
Sep 6, 2010, 9:43:57 AM9/6/10
to tins...@googlegroups.com
See www.johnhanna.us/TI-nspire.htm
Right near the top of the page.

John Hanna
jeh...@optonline.net
www.johnhanna.us
T3 - Teachers Teaching with Technology
"Reality is an approximation."

---
'Define sierpinski(a)
'Prgm

'EndPrgm
---

--
To post to this group, send email to tins...@googlegroups.com
To unsubscribe send email to tinspire+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com.au/group/tinspire?hl=en-GB?hl=en-GB
The tns documents shared by group members are archived at
http://lafacroft.com/archive/nspire.php

-TJ

unread,
Sep 6, 2010, 7:46:22 PM9/6/10
to tinspire
I really like your program, Matthew. =]

M@

unread,
Sep 8, 2010, 4:26:04 AM9/8/10
to tinspire
Yeah, it's a great way to get into the programming.

I've seen it done using Microsoft Excel, TI-83, Basic and more.
Reply all
Reply to author
Forward
0 new messages