Question: Write a Java program. To draw the Sierpinski gasket follow the algorithm: Randomly pick one of the three corners. Call this the current point. (Alternatively,
Write a Java program.

To draw the Sierpinski gasket follow the algorithm: Randomly pick one of the three corners. Call this the current point. (Alternatively, you could also randomly select any point inside the triangle). Randomly pick one of the three corners. Call this the target point. Calculate the midpoint between the current point and the target point. Draw a single pixel at the midpoint. Set the current point to the midpoint. Go back to step 2 and repeat many times (e.g., 50, 000 iterations). It would seem like you should get a random mess of dots since the algorithm randomly picks a target corner each time. Instead, if this process is repeated many times, you will get a very orderly picture with a repeating structure: To draw a single pixel at coordinate (X, Y) use the draw Line method where the start and endpoints are both (X, Y). To generate a random number x, where 0 x
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
