Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started