java - Rendering exponential and periodic Julia fractals -
i've read how render julia fractals here. i'm pretty thorough two-degree julia sets equations of form f(z)=z2+c don't know how render complex julia functions f(z) = ez - 0.65 , other complex functions involve sine , cosine. how render these type of functions? also, color mapping should used in exponential functions?
for instance want achieve following image , others given on wikipedia page.
edit :
here tried:
complexnumber.java
package plane.complex; /** * code>complexnumber</code> class implements complex numbers in java. * includes basic operations can performed on complex numbers such as, * addition, subtraction, multiplication, conjugate, modulus , squaring. * * @author abdul fatir * @version 1.0 * */ public class complexnumber { /** * real, re(z), part of <code>complexnumber</code>. */ private double real; /** * imaginary, im(z), part of <code>complexnumber</code>. */ private double imaginary; /** * constructs new <code>complexnumber</code> object both real , imaginary parts 0 (z = 0 + 0i). */ public complexnumber() { real = 0.0; imaginary = 0.0; } /** * constructs new <code>complexnumber</code> object. * @param real real part, re(z), of complex number * @param imaginary imaginary part, im(z), of complex number */ public complexnumber(double real, double imaginary) { this.real = real; this.imaginary = imaginary; } /** * adds <code>complexnumber</code> current complex number. * @param complex_number complex number added current complex number */ public void add(complexnumber complex_number) { this.real = this.real + complex_number.real; this.imaginary = this.imaginary + complex_number.imaginary; } /** * complex conjugate of current complex number. * @return <code>complexnumber</code> object conjugate of current complex number */ public complexnumber conjugate() { return new complexnumber(this.real,-this.imaginary); } /** * modulus, magnitude or absolute value of current complex number. * @return magnitude or modulus of current complex number */ public double mod() { return math.sqrt(math.pow(this.real,2) + math.pow(this.imaginary,2)); } /** * square of current complex number. * @return <code>complexnumber</code> object square of current complex number */ public complexnumber square() { double _real = this.real*this.real - this.imaginary*this.imaginary; double _imaginary = 2*this.real*this.imaginary; return new complexnumber(_real,_imaginary); } /** * multiplies <code>complexnumber</code> current complex number. * @param complex_number complex number multiplied current complex number */ public void multiply(complexnumber complex_number) { double _real = this.real*complex_number.real - this.imaginary*complex_number.imaginary; double _imaginary = this.real*complex_number.imaginary + this.imaginary*complex_number.real; this.real = _real; this.imaginary = _imaginary; } /** * prints complex number in x + yi format */ @override public string tostring() { return this.real+" + "+this.imaginary+"i"; } /** * calculates exponential of <code>complexnumber</code> * @param complex_number input complex number * @return <code>complexnumber</code> e^(input complex_number) */ public static complexnumber exp(complexnumber complex_number) { double = complex_number.real; double b = complex_number.imaginary; = math.exp(a)*math.cos(b); b = math.exp(a)*math.sin(b); return new complexnumber(a,b); } }
here how tried render:
for(int x=0; x<width; x++) { for(int y=0; y<height; y++) { complexnumber oldz = new complexnumber(); complexnumber newz = new complexnumber(2.0*(x-width/2)/(width/2), 1.33*(y-height/2)/(height/2) ); int i; for(i=0;i<max_iter; i++) { oldz = newz; newz=complexnumber.exp(newz); newz.add(constant); if(newz.mod() > 2) break; } float brightness = < max_iter ? 1f : 0; float hue = i%256 /255.0f; color color = color.gethsbcolor(hue, saturation, brightness); img.setrgb(x,y, color); } }
in exp function, used value a
again after changing it, requiring in unchanged version. replace with
public static complexnumber exp(complexnumber complex_number) { double = complex_number.real; double b = complex_number.imaginary; double r = math.exp(a); = r*math.cos(b); b = r*math.sin(b); return new complexnumber(a,b); }
Comments
Post a Comment