-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComplexIterable.pde
More file actions
95 lines (88 loc) · 2.54 KB
/
Copy pathComplexIterable.pde
File metadata and controls
95 lines (88 loc) · 2.54 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
class MandelbrotIterable extends ComplexBinaryFunction {
final double bailout2 = 4;
String name(){return "Mandelbrot: w^2 + z";}
Complex f(Complex c){return c;}
Complex f(Complex z, Complex c) {
Complex out = z.square().add(c);
if(out.mag2() >= bailout2){
return new Complex(Double.NaN,Double.NaN);
} else {
return out;
}
}
}
class CubelbrotIterable extends ComplexBinaryFunction {
final double bailout2 = 4;
String name(){return "Cubelbrot: w^3 + z";}
Complex f(Complex c){return c;}
Complex f(Complex z, Complex c) {
Complex out = z.cube().add(c);
if(out.mag2() >= bailout2){
return new Complex(Double.NaN,Double.NaN);
} else {
return out;
}
}
}
class BurningShipIterable extends ComplexBinaryFunction {
final double bailout2 = 4;
String name(){return "Burning Ship: (|Re(w)| + |Im(w)|)^2 - z";}
Complex f(Complex c){return c;}
Complex f(Complex z, Complex c) {
Complex out = z.elementAbs().square().add(c);
if(out.mag2() >= bailout2){
return new Complex(Double.NaN,Double.NaN);
} else {
return out;
}
}
}
class MobiusIterable extends ComplexBinaryFunction{
final Complex I = new Complex(0, 1);
String name(){return "Mobius: (w+iz)/(w-iz)";}
Complex f(Complex c){return new Complex(-1,0);}
Complex f (Complex z, Complex c) {
return z.add(c.mult(I)).divBy(z.mult(I).add(c));
}
}
class TrigIterable extends ComplexBinaryFunction {
final double bailout2 = 4;
final Complex ONE = new Complex(1,0);
String name(){return "2*(1-cos(w)) + z";}
Complex f(Complex c){return c;}
Complex f(Complex z, Complex c) {
Complex out = z.cos().subFrom(ONE).mult(2).add(c);
if(out.mag2() >= bailout2){
return new Complex(Double.NaN,Double.NaN);
} else {
return out;
}
}
}
class HyperbolicIterable extends ComplexBinaryFunction {
final double bailout2 = 4;
final Complex ONE = new Complex(1,0);
String name(){return "2*(cosh(w) - 1) + z";}
Complex f(Complex c){return c;}
Complex f(Complex z, Complex c) {
Complex out = z.cosh().sub(ONE).mult(2).add(c);
if(out.mag2() >= bailout2){
return new Complex(Double.NaN,Double.NaN);
} else {
return out;
}
}
}
class ExponentialIterable extends ComplexBinaryFunction {
final double bailout2 = 4;
String name(){return "e^z + c";}
Complex f(Complex c){return c;}
Complex f(Complex z, Complex c) {
Complex out = z.exp().add(c);
if(out.mag2() >= bailout2){
return new Complex(Double.NaN,Double.NaN);
} else {
return out;
}
}
}