Jump to content

Talk:Sierpinski triangle/Image credits

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

The given algorithm needs Θ(4^n) time to construct an n-level triangle, but since the triangle contains only O(3^n) points, there's a faster, recursive way:

 Sierp(x0,y0,x1,y1,x2,y2):
 // creates a Sierpinski triangle with vertices (x0,y0), (x1,y1), (x2,y0), which are given in counterclockwise order.
    if (the three points are equal) 
      plot (x0,y0);
      return;
    Let (u0,v0) be the midpoint of the segment from (x0,y0) to (x1,y1) and let (u1,v1) be the midpoint of the segment from (x1,y1) to (x2,y2) and let (u2,v2) be the midpoint of the segment from (x2,y2) to (x0,y0).
    Sierp(x0,y0,u0,v0,u2,v2);
    Sierp(u0,v0,x1,y1,u1,v1);
    Sierp(u2,v2,u1,v1,x2,y2);

AxelBoldt


Ack! Subpages! -- Zoe