A sierpinski gasket or triangle is a type of fractal named


Question: A Sierpinski Gasket or Triangle is a type of fractal named after the Polish mathematician Waclaw Sierpinski who described some of its interesting properties in 1916. It is a nice example of how an orderly structure can be created as a result of random, chaotic behavior.

One way to create the fractal is to start with an equilateral triangle. Let us say that the corners are labeled X, Y, and Z.

1. Set current equal to point X.

2. Repeat many times (you can try 10000).

a. Randomly pick target as one of the three X, Y, or Z.

b. Calculate the point halfway between current and target.

c. Set current to this halfway point. d. Draw a pixel at location current. One way to do this is to fill or draw a tiny rectangle at this coordinate.

Write a program that draws a Sierpinski Gasket. You can pick the coordinates for the corners of the triangle. It may seem like you should get a random mess of dots but instead you get a very orderly picture!

To draw a single pixel at coordinate (X,Y), use the draw Line method where the start and endpoints are both (X,Y).

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: A sierpinski gasket or triangle is a type of fractal named
Reference No:- TGS02405489

Now Priced at $10 (50% Discount)

Recommended (97%)

Rated (4.9/5)