KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > chaos > CantorDust


1 package JSci.maths.chaos;
2
3 /**
4 * The CantorDust class provides an object that encapsulates the Cantor dust fractal.
5 * @version 0.1
6 * @author Mark Hale
7 */

8 public abstract class CantorDust extends Object JavaDoc {
9         public CantorDust() {}
10         public double hausdorffDimension() {
11                 return Math.log(2.0)/Math.log(3.0);
12         }
13         /**
14         * The recursive algorithm for Cantor dust.
15         * @param start the start of the line.
16         * @param end the end of the line.
17         * @param n the number of recursions.
18         */

19         public void recurse(double start, double end, int n) {
20                 if(n==0)
21                         return;
22                 final double l_3=(end-start)/3.0;
23                 eraseLine(start+l_3, end-l_3);
24                 recurse(start, start+l_3, n-1);
25                 recurse(end-l_3, end, n-1);
26         }
27         /**
28         * Erases a line segment.
29         * This need not be an actual graphical operation,
30         * but some corresponding abstract operation.
31         */

32         protected abstract void eraseLine(double start, double end);
33 }
34
35
Popular Tags