-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJulia.java
71 lines (65 loc) · 1.54 KB
/
Julia.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/***************************************************************************************
* Title: Julia
* Author: Anjana Senanayake
* Date: 15/07/2017
* Code version: v1.0
* Availability: https://github.com/AnjanaSenanayake/Mandelbrot-Julia-
*
***************************************************************************************/
public class Julia
{
protected boolean bound;
private double x_input;
private double y_input;
private double x;
private double y;
private double znow_x;
private double znow_y;
private int niter;
//Constructor Julia
public Julia(double x,double y)
{
x_input=x;
y_input=y;
}
//Maps the x,y coordinates into complex number within the region of interest
public void complexValue(double i,double j)
{
znow_x=(((double)i*2)/800)-1;
znow_y=(((double)j*2)/800)-1;
}
//Checks the complex coordinates are in the set of Julia
public boolean boundCheck(double x,double y,int iterations)
{
niter=0;
x=x_input;
y=y_input;
while(iterations-->0)
{
double znext_x=(znow_x*znow_x)-(znow_y*znow_y)+x;
double znext_y=(2*znow_x*znow_y)+y;
znow_x=znext_x;
znow_y=znext_y;
niter++;
if((Math.pow(znow_x,2)+Math.pow(znow_y,2))>4)
{
return bound=false;
}
}
return bound=true;
}
//returns x,y coordinates
public double getX()
{
return x;
}
public double getY()
{
return y;
}
//returns the number of iterations took on the boundCheck
public int getIter()
{
return niter;
}
}