Skip to content

Commit d7d0f59

Browse files
authored
Merge pull request #19 from jackyarndley/development
Development
2 parents 2933991 + 5abf822 commit d7d0f59

File tree

7 files changed

+58
-25
lines changed

7 files changed

+58
-25
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ features = ["float", "complex"]
2222

2323
#Additional commands that can improve performance (maybe by around 5-10%)
2424
[profile.release]
25-
lto = "fat"
26-
codegen-units = 1
25+
#lto = "fat"
26+
#codegen-units = 1
2727
#debug = true

default.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
image_width = 1000
22
image_height = 1000
33
frames = 1
4-
export = "colour"
4+
export = "colour"
5+
rotate = 0

long.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
real = "-1.7697392710757027841152006141906594654234779937259515247210119204006409471133661312119570293427350953111092082771973598855782759599980633037132375185987670114621045880606454417706999699982839165518556104246980851140230022353588311445547248451142336585544111916489341441418890633019730101854648463669109636471162672120817824917407218303348419898985242808140058964414457471465221536301689319210853379995524156624829942780946758964309072692484524503974031949154005423948971844113769257156823395255042997434557967120122936287886272994336827603988076644070845456535059390110455532123959338354686709501965947157116618024249418340042125809823163860665551942191883280150556503637746217516167947991343226606484863461721881250950867469305763323991190602711636193429181021868663451423240656141036481686672207216510178940927578426246138789051935948202201039069515784638090342979600881257471340705419667858851219686"
2+
imag = "0.0047957559338652178505615663220486971154304886886673920781256111752398106107280366675989298691779797136737364961830758523741254480286664920460479195128211953261155569223186412660856033539583067793744552698972305956559820659036789189846739491155635838617923497250059314208186984179036223826655324004181421335633738898275114135499319014247271095039118772708132302750547913645230844806438628351797278101552420985568133578867374426937467785916207019758747794073870494765108717384461786347756065294984135627296206900076429271573756624100323471123560470223626746460265018297930359289043411279245762239698772188260974285993117734181827318766613834051977484272020698249213489627750957498023989747438133307647274695802671234943834981584342636056200655633883556867650337796993091229444120358050723663523120235639704136824323264324209617146569763642761341662189958962136924719552069482293150925374378282906250039"
3+
zoom = "5E894"
4+
iterations = 200000

opus2.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
real = "-0.749999987350877481864108888020013802837969258626230419972587823828734338471228477079750588709551510361714463695461745528645748607681279674273355384334270208362211787387351792878073779449767291526542817531261340190806632565918259326812453945339010150589328574149762103412720468461829229717752036030894096315543168284825591829523451459881790177201252306571105765519675248512352116833573251629567483327363311905069239003032701051529457481196547434321797050981253335937568089213120462566208183651115805653397293307377258559233202903277271676210602323914213229679532680425641573037323936099296977383315509031245712699863469264931916441084524494037606498168268686721923874005066873080025308977190880377994951387503602088911332670208047338589057179189242986041326869049326695151373694471831244401593898610875755534119908741965159514391743447026006739832349691851901398357322220"
2+
imag = "0.001000038688236832013124581230049849132759425863378894883003211011278068229551274712347955044740933397589760194545872789087012331273586364914484522575986336846199522726507205442204060303594955245291999525338163887733776425296885360624117754790016039295518748100994374326514266548379714091150515954338609920973073364107748619320475410623673220046896479022827825993708176842163391900758089808211644753443666550081714232493619984139688643050056804682336073778593187461493553160679031928537192970767012461077854087872615079724603280623855121742482968568427025472006277692061641900496152974606824700919966353741349586737424130832293811657136609787251540732986491711380483513615806577672347051574909062756851877529226144646342697709731384260107991407404869126271382608377517199011953183918273014546327019813569447081536980717484300757693838699772312217708489638932599104037840"
3+
zoom = "8.1339E864"
4+
iterations = 80000000

orion.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
real = "-0.7499999873508774818641088880200138028379692586262304199725878238287343384712284770797505887095515103617144636954617455286457486076812796742733553843342702083622117873873517928780737794497672901267230430626297336988810230734399361344818375773549399347875427428347264988553944011302460192928350281876904124203104238715822950990748008617950706353815706458979765197961555377834051564401967392434897239319"
2+
imag = "0.0010000386882368320131245812300498491327594258633788948830032110112780682295512747123479550447409333975897601945458727890870123312735863649144845225759863368461995227265072054422040603035949595533881367262322728165337116691191170116264549163097731201190091878205909302494936965023533854506636169170005449301928128392733712616089780239330345939551040094373518357099774818911598783954917116723235106496"
3+
zoom = "1E394"
4+
iterations = 20000000

src/renderer.rs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use crate::util::{data_export::*, ComplexFixed, ComplexArbitrary, PixelData, complex_extended::ComplexExtended, float_extended::FloatExtended, string_to_extended, extended_to_string};
1+
use crate::util::{data_export::*, ComplexFixed, ComplexArbitrary, PixelData, complex_extended::ComplexExtended, float_extended::FloatExtended, string_to_extended, extended_to_string, get_approximation_terms, get_delta_top_left};
22
use crate::math::{SeriesApproximation, Perturbation, Reference};
33

44
use std::time::Instant;
5-
use std::cmp::{min, max};
65
use std::io::Write;
6+
use std::cmp::max;
77

88
use rand::seq::SliceRandom;
99
use rayon::prelude::*;
@@ -12,7 +12,7 @@ use config::Config;
1212
pub struct FractalRenderer {
1313
image_width: usize,
1414
image_height: usize,
15-
aspect: f64,
15+
rotate: f64,
1616
zoom: FloatExtended,
1717
maximum_iteration: usize,
1818
glitch_tolerance: f64,
@@ -28,6 +28,7 @@ impl FractalRenderer {
2828
pub fn new(settings: Config) -> Self {
2929
let image_width = settings.get_int("image_width").unwrap_or(1000) as usize;
3030
let image_height = settings.get_int("image_height").unwrap_or(1000) as usize;
31+
let rotate = settings.get_float("rotate").unwrap_or(0.0).to_radians();
3132
let maximum_iteration = settings.get_int("iterations").unwrap_or(1000) as usize;
3233
let initial_zoom = settings.get_str("zoom").unwrap_or(String::from("1E0")).to_ascii_uppercase();
3334
let center_real = settings.get_str("real").unwrap_or(String::from("-0.75"));
@@ -44,24 +45,14 @@ impl FractalRenderer {
4445
};
4546
let display_glitches = false;
4647

47-
let aspect = image_width as f64 / image_height as f64;
4848
let zoom = string_to_extended(&initial_zoom);
49-
5049
let delta_pixel = (-2.0 * (4.0 / image_height as f64 - 2.0) / zoom) / image_height as f64;
51-
5250
let radius = delta_pixel * image_width as f64;
5351
let precision = max(64, -radius.exponent + 64);
54-
5552
let center_location = ComplexArbitrary::with_val(
5653
precision as u32,
5754
ComplexArbitrary::parse("(".to_owned() + &center_real + "," + &center_imag + ")").expect("Location is not valid!"));
58-
59-
let auto_approximation = if approximation_order == 0 {
60-
let auto = (((image_width * image_height) as f64).log(1e6).powf(6.619) * 16.0f64) as usize;
61-
min(max(auto, 3), 64)
62-
} else {
63-
approximation_order
64-
};
55+
let auto_approximation = get_approximation_terms(approximation_order, image_width, image_height);
6556

6657
let reference = Reference::new(center_location.clone(), center_location.clone(), 1, maximum_iteration);
6758
let series_approximation = SeriesApproximation::new_central(&center_location,
@@ -73,7 +64,7 @@ impl FractalRenderer {
7364
FractalRenderer {
7465
image_width,
7566
image_height,
76-
aspect,
67+
rotate,
7768
zoom,
7869
maximum_iteration,
7970
glitch_tolerance,
@@ -100,12 +91,16 @@ impl FractalRenderer {
10091
self.series_approximation.generate_approximation(&self.center_reference);
10192
}
10293

103-
let delta_pixel = (-2.0 * (4.0 / self.image_height as f64 - 2.0) / self.zoom.mantissa) / self.image_height as f64;
104-
// This should be the delta relative to the image, without the big zoom factor applied.
105-
let delta_top_left = ComplexFixed::new((4.0 / self.image_width as f64 - 2.0) / self.zoom.mantissa * self.aspect as f64, (4.0 / self.image_height as f64 - 2.0) / self.zoom.mantissa);
94+
let cos_rotate = self.rotate.cos();
95+
let sin_rotate = self.rotate.sin();
96+
let delta_pixel = 4.0 / ((self.image_height - 1) as f64 * self.zoom.mantissa);
97+
let delta_top_left = get_delta_top_left(delta_pixel, self.image_width, self.image_height, cos_rotate, sin_rotate);
98+
10699
let delta_pixel_extended = FloatExtended::new(delta_pixel, -self.zoom.exponent);
107100

108101
self.series_approximation.delta_pixel_square = delta_pixel_extended * delta_pixel_extended;
102+
103+
// Used for placing the probe points
109104
self.series_approximation.delta_top_left = ComplexExtended::new(delta_top_left, -self.zoom.exponent);
110105
self.series_approximation.check_approximation();
111106

@@ -119,9 +114,13 @@ impl FractalRenderer {
119114
.map(|index| {
120115
let i = index % self.image_width;
121116
let j = index / self.image_width;
122-
let element = ComplexFixed::new(i as f64 * delta_pixel + delta_top_left.re, j as f64 * delta_pixel + delta_top_left.im);
117+
// This could be changed to account for rotation, and jittering if needed
118+
let element = ComplexFixed::new(
119+
i as f64 * delta_pixel * cos_rotate - j as f64 * delta_pixel * sin_rotate + delta_top_left.re,
120+
i as f64 * delta_pixel * sin_rotate + j as f64 * delta_pixel * cos_rotate + delta_top_left.im
121+
);
122+
123123
let point_delta = ComplexExtended::new(element, -self.zoom.exponent);
124-
125124
let new_delta = self.series_approximation.evaluate(point_delta, None);
126125

127126
PixelData {
@@ -148,7 +147,6 @@ impl FractalRenderer {
148147
print!("| {:<15}", iteration_time.elapsed().as_millis());
149148
std::io::stdout().flush().unwrap();
150149

151-
152150
let correction_time = Instant::now();
153151

154152
// Remove all non-glitched points from the remaining points
@@ -184,7 +182,6 @@ impl FractalRenderer {
184182

185183
print!("| {:<15}", correction_time.elapsed().as_millis());
186184
std::io::stdout().flush().unwrap();
187-
188185

189186
let saving_time = Instant::now();
190187
self.data_export.save(&filename);

src/util/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::f64::consts::{LOG2_10, LOG10_2};
2+
use std::cmp::{min, max};
23

34
pub mod data_export;
45
pub mod float_extended;
@@ -74,6 +75,28 @@ pub fn extended_to_string(value: FloatExtended) -> String {
7475
format!("{:.2}E{}", first * 10.0f64.powf(second.fract()), second.floor() as i32)
7576
}
7677

78+
pub fn get_delta_top_left(delta_pixel: f64, image_width: usize, image_height: usize, cos_rotate: f64, sin_rotate: f64) -> ComplexFixed<f64> {
79+
let aspect = image_width as f64 / image_height as f64;
80+
81+
let temp_real = -0.5 * (image_height - 1) as f64 * delta_pixel * aspect as f64;
82+
let temp_imag = -0.5 * (image_height - 1) as f64 * delta_pixel;
83+
84+
ComplexFixed::new(
85+
temp_real * cos_rotate - temp_imag * sin_rotate,
86+
temp_real * sin_rotate + temp_imag * cos_rotate)
87+
}
88+
89+
pub fn get_approximation_terms(approximation_order: usize, image_width: usize, image_height: usize) -> usize {
90+
if approximation_order == 0 {
91+
let auto = (((image_width * image_height) as f64).log(1e6).powf(6.619) * 16.0f64) as usize;
92+
min(max(auto, 3), 64)
93+
} else {
94+
approximation_order
95+
}
96+
}
97+
98+
99+
77100
#[derive(Clone)]
78101
pub struct PixelData {
79102
pub image_x: usize,

0 commit comments

Comments
 (0)