Skip to content

Commit a53a4c1

Browse files
committed
added automatic series approximation terms calculation
1 parent e56fa1f commit a53a4c1

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

output.png

-53.5 MB
Loading

src/bin/main.rs

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

5555
let mut renderer = FractalRenderer::new(
56-
5000,
57-
5000,
56+
1000,
57+
1000,
5858
zoom,
5959
iterations.parse::<usize>().unwrap(),
6060
center_re,
6161
center_im,
6262
0.01,
6363
false,
64-
32
64+
0
6565
);
6666

6767
let time = Instant::now();

src/renderer.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::util::{image::Image, ComplexFixed, ComplexArbitrary, PixelData, compl
22
use crate::math::{SeriesApproximation, Perturbation};
33

44
use std::time::Instant;
5-
use std::cmp::max;
5+
use std::cmp::{min, max};
66
use std::f64::consts::LOG2_10;
77

88
use rand::seq::SliceRandom;
@@ -46,14 +46,21 @@ impl FractalRenderer {
4646
precision as u32,
4747
ComplexArbitrary::parse("(".to_owned() + center_real + "," + center_imag + ")").expect("Location is not valid!"));
4848

49+
let auto_approximation = if approximation_order == 0 {
50+
let auto = (((image_width * image_height) as f64).log(1e6).powi(2) * 21.0f64) as usize;
51+
min(max(auto, 3), 64)
52+
} else {
53+
approximation_order
54+
};
55+
4956
FractalRenderer {
5057
image_width,
5158
image_height,
5259
aspect,
5360
zoom,
5461
center_location,
5562
maximum_iteration,
56-
approximation_order,
63+
approximation_order: auto_approximation,
5764
glitch_tolerance,
5865
image: Image::new(image_width, image_height, display_glitches)
5966
}

0 commit comments

Comments
 (0)