Okay, so today I tried to create a bigger program that would draw the Sierpinski Triangle with a given side length and a given number of levels.
However I afterwards realized that it doesnt function quite as it should hehe. The first 2 levels look fine but then I cant get the height (y-value) to fit for the rest.
The approach I took was i found what the width and height of the triangles drawn were at a given level (was something like 1/2^n-1 * side lenght) and then simply used some for loops calculated from the number of levels given.
A different approach I tried later on (worked fine on the computer by the way, C++) was with recursive programming. Meaning I had a program to draw the triangles and then recalling it self until the number of given levels were reached.
The pseudo code for the function was something like this:
function DrawTriangle(n, x1, y1, x2, y2, x3, y3)
Draw triangle from points given;
If (n < max level)
DrawTriangle(n+1, new x/y values for the left triangle);
DrawTriangle(n+1, new x/y values for the top triangle);
DrawTriangle(n+1, new x/y values for the right triangle);
And now im pretty open for any ideas hehe. Just not the boring randomizing / chaos game method of drawing the triangle ;)
Hope someones interested in aiding me in this minor problem ^^