Here are two programs I created for my TI84+CE that draws a Sierpinski square (well, 2/3rds of one anyways). The first one draws a small square, creating a larger square as it goes. The second one draws pixels at different screen positions filling in the pattern as it runs. Because of the screen size, I can only draw 2/3rds of the square at the size Iím drawing. It takes 6min, 30seconds to complete the drawing. There are several FOR loops, but at some point I might try to make it recursive on my calculator. I have it recursive on my iPad which draws the full square instantly. I also have code on my iPad that draws an 81x81x81 Sierpenski cube in about 2 seconds.

Just a note, there are 2 programs listed. They should be loaded separately.

I changed the 81 value for loops to 0 so the program stops after drawing 2/3rds even though I have an if statement which prevents drawing off screen.


Code:

ClrDraw
For I,-81,0,81
For J,-81,81,81
If I≠0 or J≠0:Then
For G,-27,27,27
For H,-27,27,27
If G≠0 or H≠0:Then
For E,-9,9,9
For F,-9,9,9
If E≠0 or F≠0:Then
For C,-3,3,3
For D,-3,3,3
If C≠0 or D≠0:Then
For A,-1,1,1
For B,-1,1,1
If A≠0 or B≠0:Then
A+C+E+G+I+121→Y
B+D+F+H+J+132→X
If Y≥0 and Y≤164:Then
Pxl-On(Y,X,RED)
End:End:End:End
End:End:End:End
End:End:End:End
End:End:End:End



ClrDraw
For I,-1,1,1
For J,-1,1,1
If I≠0 or J≠0:Then
For G,-3,3,3
For H,-3,3,3
If G≠0 or H≠0:Then
For E,-9,9,9
For F,-9,9,9
If E≠0 or F≠0:Then
For C,-27,27,27
For D,-27,27,27
If C≠0 or D≠0:Then
For A,-81,0,81
For B,-81,81,81
If A≠0 or B≠0:Then
A+C+E+G+I+121→Y
B+D+F+H+J+132→X
If Y≥0 and Y≤164:Then
Pxl-On(Y,X,RED)
End:End:End:End
End:End:End:End
End:End:End:End
End:End:End:End
Weregoose wrote:
Sierpinski Triangle
Inputs: None
Outputs: IFS-generated Sierpinski sieve fractal


Code:
:0
:Repeat 0
:.5(Ans+e^(.5iπint(3rand
:Pt-On(real(Ans),imag(Ans
:End

Evil or Very Mad
mr womp womp

Thanks for the response. Unfortunately, the code doesnít work. At first I was getting an error, then I figured I should try setting the calc to radians. The code ran, but all it does is put a couple of dots in the center of the screen. I let it run for awhile, but nothing but a few dots. Anyways, your response comment says Sierpinski Triangle. Iím drawing a Sierpinski square. I would try for a Sierpinski cube, but Iím not sure how well it would show on the calculator. I think the TI84+CE can do 3D, havenít look into it.
In my code, if I remove the If statement just before the Pxl-On statement and one of the End statements, it runs faster and takes 5min, 29seconds. Since I limit the last 1/3rd of the square in one of the FOR statements, I can eliminate that If statement since the program ends before it tries to plot off screen.
dave1707 wrote:
mr womp womp

Thanks for the response. Unfortunately, the code doesnít work. At first I was getting an error, then I figured I should try setting the calc to radians. The code ran, but all it does is put a couple of dots in the center of the screen. I let it run for awhile, but nothing but a few dots. Anyways, your response comment says Sierpinski Triangle. Iím drawing a Sierpinski square. I would try for a Sierpinski cube, but Iím not sure how well it would show on the calculator. I think the TI84+CE can do 3D, havenít look into it.

Yeah your window settings are probably wrong.
Make sure Xmin=-1, Xmax=1, Ymin=0, Ymax=1.

mr womp womp Thanks. I donít know what the last thing I ran that changed the values, but they were like +/- in the thousands. I donít play with the calculator that often, so I donít think of looking at the graph values.
For posterity, my code that got posted above already had an update three years later.

Edited to add: Tweaking said code gives the Sierpinski carpet as:


Code:
:1
:Repeat 0
:Ans/3+iPart(2i^(.5int(8rand
:Pt-On(real(Ans),imag(Ans
:End
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement