Computer Science Canada Serpinsky Triangle with recursion |
Author: | BenLi [ Tue May 02, 2006 3:17 pm ] | ||
Post subject: | Serpinsky Triangle with recursion | ||
Hey, this is my first attempt at recursion, probably going to make a fractal tree next
actually, its not actually a serpinsky yet... |
Author: | zylum [ Tue May 02, 2006 3:54 pm ] | ||
Post subject: | |||
suggestion: make sure you have a terminating condition for your recursion. if you let your program run long enough, it eats up all the memory and crashes. also, like you mentioned, its not quite a serpinsky triangle. an easy way to make a serpinsky triangle is to draw your beginning triangle, then half way between its centre and each of its vertices, draw another one half its size.
good luck with your fractal tree and recursion ![]() ![]() |
Author: | MysticVegeta [ Tue May 02, 2006 5:43 pm ] |
Post subject: | |
zylum, I haven't taken grade 11 trig yet, can you guide me over what is happening in the draw polygon? I understand the recursion but I dont understand how you come up with values for the x and y array, I know they represent the vertices of the triangle, but dont know whats going on in them, lol |
Author: | HellblazerX [ Tue May 02, 2006 7:24 pm ] |
Post subject: | |
First of all, drawpolygon takes in an array of coordinates to draw the polygon. A triangle has three points, so he puts in an array of 3 x coordinates and an array of 3 y coordinates to draw the triangle. To get the x and y coordinates, he just takes the trigonometric values of them in the unit circle, and mulitplying by the size of the triangle. This way he can resize the triangles very easily. |
Author: | zylum [ Tue May 02, 2006 9:00 pm ] |
Post subject: | |
what ^he^ said ![]() |
Author: | MysticVegeta [ Wed May 03, 2006 1:39 pm ] |
Post subject: | |
HellblazerX wrote: First of all, drawpolygon takes in an array of coordinates to draw the polygon. A triangle has three points, so he puts in an array of 3 x coordinates and an array of 3 y coordinates to draw the triangle. To get the x and y coordinates, he just takes the trigonometric values of them in the unit circle, and mulitplying by the size of the triangle. This way he can resize the triangles very easily.
yeah I know that but I asked, how to "come up" withthe x and y vals, just the trig part I have a hard time understanding... |