jadex.micro.examples.mandelbrot.MandelbrotAlgorithm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-micro Show documentation
Show all versions of jadex-applications-micro Show documentation
The Jadex micro applications package contains several example applications, benchmarks and testcases using micro agents.
package jadex.micro.examples.mandelbrot;
/**
* Algorithm for calculating the mandelbrot set.
*/
public class MandelbrotAlgorithm implements IFractalAlgorithm
{
//-------- IFractalAlgorithm interface --------
/**
* Determine the color of a point.
* @param x The x coordinate.
* @param y The y coordinate.
* @param max The maximum depth.
* @return A value for the point from 0 to max.
*/
public short determineColor(double xn, double yn, short max)
{
double x0 = xn;
double y0 = yn;
short i = 0;
double c = Math.sqrt(xn*xn + yn*yn);
for(i=0; c<2 && i