JuliaOperator (java)

De GirinoWiki

package org.girino.frac.operators;
 
import java.applet.Applet;
 
import org.girino.frac.Complex;
import org.girino.frac.FractalOperator;
 
/**
 * operator for mandelbrot sets.. 
 * 
 * much simple than buddhabrot, huh?
 * @author girino
 *
 */
public class JuliaOperator implements FractalOperator {
 
	private static final double omega = 4.0;
	private Complex C = new Complex(0.285,0.013); 
 
	/**
	 * yeah,m teh old stuff, Z = Z^2 + C. but now I get to iterate over Z, no C.
	 * C is fixed.
	 */
	public int apply(double x, double y, int maxiter) {
	    Complex Z = new Complex(x,y);
	    int j = 0;
 
	    for(j = 0; (j < maxiter) && (Complex.modulus(Z) <= omega);j++) 
	      Z = Complex.add(Complex.square(Z),C);
 
	    return j;
	}
 
	public void init(Applet config) {
		double cx = 0.285;
		if (config.getParameter("cx") != null) {
			cx = Double.parseDouble(config.getParameter("cx"));
		}
		double cy = 0;
		if (config.getParameter("cy") != null) {
			cy = Double.parseDouble(config.getParameter("cy"));
		}
		this.C = new Complex(cx, cy);
	}
 
}
Ferramentas pessoais
Social Blogging
  • StumbleUpon
  • Adicionar aos Favoritos BlogBlogs
  • Adicionar esta página no Linkk
  • Add to Technorati Favorites
patrocinadores
Espaço comercial