Sierpinski Carpet - Construction

Construction

The construction of the Sierpinski carpet begins with a square. The square is cut into 9 congruent subsquares in a 3-by-3 grid, and the central subsquare is removed. The same procedure is then applied recursively to the remaining 8 subsquares, ad infinitum. The Hausdorff dimension of the carpet is log 8/log 3 ≈ 1.8928.

The area of the carpet is zero (in standard Lebesgue measure).

The Sierpinski carpet can also be created by iterating every pixel in a square and using the following algorithm to decide if the pixel is filled. The following implementation is valid C, C++, and Java.

/** * Decides if a point at a specific location is filled or not. This works by iteration first checking if * the pixel is unfilled in successively larger squares or cannot be in the center of any larger square. * @param x is the x coordinate of the point being checked with zero being the first pixel * @param y is the y coordinate of the point being checked with zero being the first pixel * @return 1 if it is to be filled or 0 if it is open */ int isSierpinskiCarpetPixelFilled(int x, int y) { while(x>0 || y>0) // when either of these reaches zero the pixel is determined to be on the edge // at that square level and must be filled { if(x%3==1 && y%3==1) //checks if the pixel is in the center for the current square level return 0; x /= 3; //x and y are decremented to check the next larger square level y /= 3; } return 1; // if all possible square levels are checked and the pixel is not determined // to be open it must be filled }

Read more about this topic:  Sierpinski Carpet

Famous quotes containing the word construction:

    Striving toward a goal puts a more pleasing construction on our advance toward death.
    Mason Cooley (b. 1927)

    There’s no art
    To find the mind’s construction in the face:
    He was a gentleman on whom I built
    An absolute trust.
    William Shakespeare (1564–1616)

    There’s no art
    To find the mind’s construction in the face.
    William Shakespeare (1564–1616)