From 614c03cc1b8eb508d6ed3c698dfa3bc3a6936ca9 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 5 Jun 2015 15:57:28 +0200 Subject: Cleanup; javadoc --- .../camilstaps/mandelbrot/MandelbrotFractal.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java') diff --git a/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java b/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java index 43909fe..ec05939 100644 --- a/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java +++ b/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java @@ -39,11 +39,24 @@ public class MandelbrotFractal { */ private static final Map mandelNumbers = new HashMap<>(); + /** + * Calculate the Mandelbrot number for a specific point up to some maximum + * @param x the x coordinate of the point + * @param y the y coordinate of the point + * @param repetitions the maximum + * @return the mandelbrot number + */ public synchronized static int mandelNumber(double x, double y, int repetitions) { Point p = new Point(x, y); return mandelNumber(p, repetitions); } + /** + * Calculate the Mandelbrot number for a specific point up to some maximum + * @param p the point + * @param repetitions the maximum + * @return the mandelbrot number + */ public synchronized static int mandelNumber(Point p, int repetitions) { if (mandelNumbers.containsKey(p)) { Result result = mandelNumbers.get(p); @@ -61,6 +74,12 @@ public class MandelbrotFractal { } } + /** + * Calculate the Mandelbrot number for a specifc point up to some maximum + * @param p the point + * @param repetitions the maximum + * @return the result + */ protected synchronized static Result calculateMandelNumber(Point p, int repetitions) { Result start = new Result(); start.x = p.x; @@ -69,6 +88,13 @@ public class MandelbrotFractal { return start; } + /** + * Calculate the Mandelbrot number for a specific point up to some maximum, + * starting from an earlier result + * @param p the point + * @param repetitions the maximum + * @param start the earlier result; will be updated with the new result + */ protected synchronized static void calculateMandelNumber(Point p, int repetitions, Result start) { int n = start.repetitions; @@ -82,6 +108,9 @@ public class MandelbrotFractal { start.mandelNumber = n; } + /** + * A point on a coordinate system + */ public static class Point { double x, y; @@ -113,6 +142,10 @@ public class MandelbrotFractal { } } + /** + * A Mandelbrot result consists of a point, the mandelbrot number and the + * maximum with which we calculated that result. + */ protected static class Result { int mandelNumber = -1, repetitions = 0; double x, y; -- cgit v1.2.3