Skip to content

Commit e56fa1f

Browse files
committed
further minor changes to algorithm
1 parent ad17ea4 commit e56fa1f

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

output.png

53.5 MB
Loading

src/bin/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ fn main() {
5353
println!("Zoom: {}", zoom);
5454

5555
let mut renderer = FractalRenderer::new(
56-
1000,
57-
1000,
56+
5000,
57+
5000,
5858
zoom,
5959
iterations.parse::<usize>().unwrap(),
6060
center_re,

src/math/reference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Reference {
2323
maximum_iteration,
2424
z,
2525
c,
26-
data: Vec::new()
26+
data: Vec::with_capacity(1000)
2727
}
2828
}
2929

src/math/series_approximation.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::mem::swap;
88
pub struct SeriesApproximation {
99
pub current_iteration: usize,
1010
maximum_iteration: usize,
11-
delta_pixel: FloatExtended,
11+
delta_pixel_square: FloatExtended,
1212
z: ComplexArbitrary,
1313
c: ComplexArbitrary,
1414
pub order: usize,
@@ -22,7 +22,7 @@ pub struct SeriesApproximation {
2222
}
2323

2424
impl SeriesApproximation {
25-
pub fn new(c: ComplexArbitrary, order: usize, maximum_iteration: usize, delta_pixel: FloatExtended, delta_top_left: ComplexExtended) -> Self {
25+
pub fn new(c: ComplexArbitrary, order: usize, maximum_iteration: usize, delta_pixel_square: FloatExtended, delta_top_left: ComplexExtended) -> Self {
2626
let mut coefficients = vec![ComplexExtended::new2(0.0, 0.0, 0); order as usize + 1];
2727

2828
coefficients[0] = to_extended(&c);
@@ -32,7 +32,7 @@ impl SeriesApproximation {
3232
SeriesApproximation {
3333
current_iteration: 1,
3434
maximum_iteration,
35-
delta_pixel,
35+
delta_pixel_square,
3636
z: c.clone(),
3737
c,
3838
order,
@@ -95,16 +95,16 @@ impl SeriesApproximation {
9595
derivative_probe += self.next_coefficients[k] * self.approximation_probes_derivative[i][k - 1];
9696
};
9797

98-
let relative_error = (self.current_probes[i] - series_probe).norm();
99-
let mut derivative = derivative_probe.norm();
98+
let relative_error = (self.current_probes[i] - series_probe).norm_square();
99+
let mut derivative = derivative_probe.norm_square();
100100

101101
// Check to make sure that the derivative is greater than or equal to 1
102102
if derivative.to_float() < 1.0 {
103103
derivative = FloatExtended::new(1.0, 0);
104104
}
105105

106106
// Check that the error over the derivative is less than the pixel spacing
107-
if relative_error / derivative > self.delta_pixel {
107+
if relative_error / derivative > self.delta_pixel_square {
108108
self.z -= &self.c;
109109
self.z.sqrt_mut();
110110
return false;
@@ -146,7 +146,7 @@ impl SeriesApproximation {
146146
delta_probe_n_derivative_2.push(ComplexExtended::new2(1.0, 0.0, 0));
147147

148148
for i in 1..=self.order {
149-
delta_probe_n_derivative_2.push((delta_probe_n * (i + 1) as f64));
149+
delta_probe_n_derivative_2.push(delta_probe_n * (i + 1) as f64);
150150
delta_probe_n *= delta_probe;
151151
delta_probe_n_2.push(delta_probe_n);
152152
}

src/renderer.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,15 @@ impl FractalRenderer {
6969

7070
println!("Rendering...");
7171

72+
let delta_pixel_extended = FloatExtended::new(delta_pixel, -self.zoom.exponent);
73+
7274
// Series approximation currently has some overskipping issues
7375
// this can be resolved by root finding and adding new probe points
7476
let mut series_approximation = SeriesApproximation::new(
7577
self.center_location.clone(),
7678
self.approximation_order,
7779
self.maximum_iteration,
78-
FloatExtended::new(delta_pixel, -self.zoom.exponent),
80+
delta_pixel_extended * delta_pixel_extended,
7981
ComplexExtended::new(delta_top_left, -self.zoom.exponent),
8082
);
8183

0 commit comments

Comments
 (0)