Write an applet that develops a Sierpinski triangle and the GUI interface to it. The Sierpinski triangle generation algorithm is given in Savitch’s book (3rd edition) on pp 1061-2. That text is reproduced here.
Write a program that draws a Sierpinski gasket. A Sierpinski gasket or triangle is a type of fractal. It is an example of how an orderly structure can be created as a result of random, chaotic behavior.
The creation of a Sierpinski gasket is fairly simple. There are three points that form the corners of a triangle. In the figure below, they are labeled as A, B, and C.
B (Sorry for the quality of the scheme)
To draw the Sierpinski gasket follow the algorithm:
1. Randomly pick one of the three corners. Call this the current point. (Alternatively, you could also randomly select any point inside the triangle).
2. Randomly pick one of the three corners. Call this the target point.
3. Calculate the midpoint between the current point and the target point.
4. Draw a single pixel at the midpoint.
5. Set the current point to the midpoint.
6. 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: <picture from Savitch is not reproduced here. Look at [url removed, login to view]
To draw a single pixel at coordinate (x, y) use the drawline method where the start and endpoints are both (x, y).
To generate a random number x, where 0 < x < 1, use x = [url removed, login to view]();. For example, multiplying by 3 and converting to an integer results in an integer that is from 0 to 2.
Décerné à :
25 freelance ont fait une offre moyenne de 55 € pour ce travail
Hi, I graduated computer science and I have this code already finished. If you are interested please award my bid and I will provide you code tonight. Thanks, Zeljko
Hi Sir I did this for you and will give it to you instantly for the lowest price. Please check the screen shots in your mail. I studied your requirement carefully and read more about it before doing it.
I am java programmer 6 years ago during this period i did it something similar program that draw a triangles with a mathematical algorithm. I understand that you need for this project.