From 0d00741064c92bbc69170c83b8e761b93ca5611f Mon Sep 17 00:00:00 2001 From: lat-murmeldjur Date: Wed, 27 Mar 2024 17:33:51 +0100 Subject: [PATCH] "Auto commit number 37" --- chronicl.dt | 2 +- featuring.dt | 2 +- ohio.note | 1 + src/anomaly.rs | 268 +++++++++++++++++++++--------------------- src/display_mods.rs | 37 +----- src/f32_3.rs | 23 ---- src/magma_ocean.rs | 21 +--- src/main.rs | 30 +++-- src/moving_around.rs | 30 ----- src/unused.rs.warning | 42 +++++++ 10 files changed, 199 insertions(+), 257 deletions(-) create mode 100644 src/unused.rs.warning diff --git a/chronicl.dt b/chronicl.dt index dce6588..7c09198 100644 --- a/chronicl.dt +++ b/chronicl.dt @@ -1 +1 @@ -36 \ No newline at end of file +37 \ No newline at end of file diff --git a/featuring.dt b/featuring.dt index dce6588..7c09198 100644 --- a/featuring.dt +++ b/featuring.dt @@ -1 +1 @@ -36 \ No newline at end of file +37 \ No newline at end of file diff --git a/ohio.note b/ohio.note index 4a8d414..1becb53 100644 --- a/ohio.note +++ b/ohio.note @@ -35,3 +35,4 @@ Year::2024::|::Month::03::|::Day::25::|::Hour::20::|::Minute::22::|::Second::48: Year::2024::|::Month::03::|::Day::26::|::Hour::16::|::Minute::25::|::Second::20:: Year::2024::|::Month::03::|::Day::27::|::Hour::16::|::Minute::33::|::Second::15:: Year::2024::|::Month::03::|::Day::27::|::Hour::16::|::Minute::56::|::Second::43:: +Year::2024::|::Month::03::|::Day::27::|::Hour::17::|::Minute::33::|::Second::51:: diff --git a/src/anomaly.rs b/src/anomaly.rs index 0314a62..af1e13c 100644 --- a/src/anomaly.rs +++ b/src/anomaly.rs @@ -2,47 +2,46 @@ use std::sync::mpsc; use std::thread; - use crate::f32_3::dd_f32_3; use crate::f64_3::mltply_f64_3; use crate::magma_ocean::{magma, petrify, Stone}; -use crate::positions::{move_positions}; +use crate::positions::move_positions; -pub static ts_f64: f64 = 5.391247 * 1e-44; -pub static ls_f64: f64 = 299792458.0 * 1000000000.0 * 6.1879273537329 * 1e+25; +pub static TS_F64: f64 = 5.391247 * 1e-44; +pub static LS_F64: f64 = 299792458.0 * 1000000000.0 * 6.1879273537329 * 1e+25; pub struct Anomaly { - pub Anomaly: Vec, - pub Component: Vec, - pub Force: Vec, + pub anomaly: Vec, + pub component: Vec, + pub force: Vec, } pub struct Composition { - pub Space: Vec<[f32; 3]>, - pub Distribution: Vec) -> Vec<[f32; 3]>>, + pub space: Vec<[f32; 3]>, + pub distribution: Vec) -> Vec<[f32; 3]>>, } pub struct Component { - pub Component: Vec, - pub Composition: Vec, - pub Property: Vec, + pub component: Vec, + pub composition: Vec, + pub property: Vec, } pub struct Property { - pub Name: f64, - pub Value: f64, + pub name: f64, + pub value: f64, } pub struct Force { - pub Force: Vec, - pub Range: Vec, - pub Domain: Vec, + pub force: Vec, + pub range: Vec, + pub domain: Vec, } pub fn interact(anom: &mut Anomaly) { thread::scope(|s| { let mut handles: Vec> = vec![]; - for mut a in anom.Anomaly.iter_mut() { + for mut a in anom.anomaly.iter_mut() { let handle = s.spawn(move || interact(&mut a)); handles.push(handle); } @@ -55,7 +54,7 @@ pub fn interact(anom: &mut Anomaly) { } pub fn component_interact(_anom: &mut Anomaly) { - // for f in &anom.Force { + // for f in &anom.force { // // } } @@ -63,8 +62,11 @@ pub fn component_interact(_anom: &mut Anomaly) { pub fn progress(anom: &mut Anomaly, time: f64) { thread::scope(|s| { let mut handles: Vec> = vec![]; - for mut a in anom.Anomaly.iter_mut() { - let handle = s.spawn(move || progress(&mut a, time)); + for mut a in anom.anomaly.iter_mut() { + let handle = s.spawn(move || { + interact(&mut a); + progress(&mut a, time); + }); handles.push(handle); } for h in handles { @@ -72,13 +74,13 @@ pub fn progress(anom: &mut Anomaly, time: f64) { } }); - let steps = (time / ts_f64) as u64; + let steps = (time / TS_F64) as u64; for _ in 0..steps { thread::scope(|s| { let mut handles: Vec> = vec![]; - for mut c in anom.Component.iter_mut() { + for mut c in anom.component.iter_mut() { let handle = s.spawn(move || { - component_progress(&mut c, ts_f64); + component_progress(&mut c, TS_F64); }); handles.push(handle); } @@ -91,26 +93,26 @@ pub fn progress(anom: &mut Anomaly, time: f64) { pub fn component_property(component: &mut Component, name: f64) -> f64 { let prop: Vec<&mut Property> = component - .Property + .property .iter_mut() - .filter(|c| c.Name == name) + .filter(|c| c.name == name) .collect(); - return prop[0].Value; + return prop[0].value; } pub fn component_progress(component: &mut Component, time: f64) { - for mut c in component.Component.iter_mut() { + for mut c in component.component.iter_mut() { component_progress(&mut c, time); } - let inertia_0 = component_property(component, In0); - let inertia_1 = component_property(component, In1); - let inertia_2 = component_property(component, In2); + let inertia_0 = component_property(component, IN0); + let inertia_1 = component_property(component, IN1); + let inertia_2 = component_property(component, IN2); - for c in &mut component.Composition { - for s in c.Space.iter_mut() { - let mov0 = mltply_f64_3([inertia_0, inertia_1, inertia_2], ts_f64); + for c in &mut component.composition { + for s in c.space.iter_mut() { + let mov0 = mltply_f64_3([inertia_0, inertia_1, inertia_2], TS_F64); *s = dd_f32_3(*s, [mov0[0] as f32, mov0[1] as f32, mov0[2] as f32]); } } @@ -121,7 +123,7 @@ pub fn view(anom: &mut Anomaly) -> Vec { let mut rs: Vec>> = vec![]; thread::scope(|s| { - for mut a in anom.Anomaly.iter_mut() { + for mut a in anom.anomaly.iter_mut() { let (tx, rx) = mpsc::channel(); rs.push(rx); s.spawn(move || { @@ -131,7 +133,7 @@ pub fn view(anom: &mut Anomaly) -> Vec { } }); - for c in anom.Component.iter_mut() { + for c in anom.component.iter_mut() { ret.append(&mut component_view(c)); } @@ -146,15 +148,15 @@ pub fn view(anom: &mut Anomaly) -> Vec { pub fn component_view(component: &mut Component) -> Vec { let mut ret: Vec = vec![]; - for c in component.Component.iter_mut() { + for c in component.component.iter_mut() { ret.append(&mut component_view(c)); } - let size = component_property(component, Ms); + let size = component_property(component, MS); - for c in &component.Composition { - for d in &c.Distribution { - for v in &d(c.Space.clone()) { + for c in &component.composition { + for d in &c.distribution { + for v in &d(c.space.clone()) { let mut s = petrify(magma(2, size as f32)); move_positions(&mut s.positions, *v); ret.push(s); @@ -164,26 +166,22 @@ pub fn component_view(component: &mut Component) -> Vec { ret } -pub fn add_particle(anom: &mut Anomaly, position: [f32; 3], properties: Vec) { - anom.Anomaly.push(particle(position, properties)); -} - pub fn add_particle_by(anom: &mut Anomaly, p: Anomaly) { - anom.Anomaly.push(p); + anom.anomaly.push(p); } pub fn particle(position: [f32; 3], properties: Vec) -> Anomaly { let anom = Anomaly { - Anomaly: vec![], - Component: vec![Component { - Component: vec![], - Composition: vec![Composition { - Space: vec![position], - Distribution: vec![particular], + anomaly: vec![], + component: vec![Component { + component: vec![], + composition: vec![Composition { + space: vec![position], + distribution: vec![particular], }], - Property: properties, + property: properties, }], - Force: force_base().Force, + force: force_base().force, }; anom @@ -198,13 +196,13 @@ pub fn particle(position: [f32; 3], properties: Vec) -> Anomaly { // future ref example static EC: f64 = 313.0; -static Sp: f64 = 591.0; -static Ms: f64 = 343.0; -static Cr: f64 = 0.10; -static In0: f64 = 141.0; -static In1: f64 = 141.1; -static In2: f64 = 141.2; -static QMs: [f64; 6] = [2.2, 4.7, 1.28, 96.0, 173.1, 4.18]; +static SP: f64 = 591.0; +static MS: f64 = 343.0; +static CR: f64 = 0.10; +static IN0: f64 = 141.0; +static IN1: f64 = 141.1; +static IN2: f64 = 141.2; +static QMS: [f64; 6] = [2.2, 4.7, 1.28, 96.0, 173.1, 4.18]; pub fn e(position: [f32; 3], inertia: [f64; 3], clock: bool) -> Anomaly { let sp = if clock { 0.5 } else { -0.5 }; @@ -212,28 +210,28 @@ pub fn e(position: [f32; 3], inertia: [f64; 3], clock: bool) -> Anomaly { position, vec![ Property { - Name: Sp, - Value: sp, + name: SP, + value: sp, }, Property { - Name: EC, - Value: -1.0, + name: EC, + value: -1.0, }, Property { - Name: Ms, - Value: 0.511, + name: MS, + value: 0.511, }, Property { - Name: In0, - Value: inertia[0], + name: IN0, + value: inertia[0], }, Property { - Name: In1, - Value: inertia[1], + name: IN1, + value: inertia[1], }, Property { - Name: In2, - Value: inertia[2], + name: IN2, + value: inertia[2], }, ], ) @@ -254,32 +252,32 @@ pub fn q( position, vec![ Property { - Name: Sp, - Value: sp, + name: SP, + value: sp, }, Property { - Name: EC, - Value: ch, + name: EC, + value: ch, }, Property { - Name: Ms, - Value: QMs[(flavor % 6) as usize], + name: MS, + value: QMS[(flavor % 6) as usize], }, Property { - Name: Cr, - Value: (color % 6) as f64, + name: CR, + value: (color % 6) as f64, }, Property { - Name: In0, - Value: inertia[0], + name: IN0, + value: inertia[0], }, Property { - Name: In1, - Value: inertia[1], + name: IN1, + value: inertia[1], }, Property { - Name: In2, - Value: inertia[2], + name: IN2, + value: inertia[2], }, ], ) @@ -291,81 +289,85 @@ pub fn particular(coordinates: Vec<[f32; 3]>) -> Vec<[f32; 3]> { pub fn force_base() -> Force { return Force { - Force: vec![ + force: vec![ // S Force { - Force: vec![], - Range: vec![1e-15], - Domain: vec![Component { - Component: vec![], - Composition: vec![], - Property: vec![Property { - Name: Cr, - Value: 1.0, + force: vec![], + range: vec![1e-15], + domain: vec![Component { + component: vec![], + composition: vec![], + property: vec![Property { + name: CR, + value: 1.0, }], }], }, // EM Force { - Force: vec![], - Range: vec![f64::MAX], - Domain: vec![Component { - Component: vec![], - Composition: vec![], - Property: vec![Property { - Name: EC, - Value: 1.0 / 137.0, + force: vec![], + range: vec![f64::MAX], + domain: vec![Component { + component: vec![], + composition: vec![], + property: vec![Property { + name: EC, + value: 1.0 / 137.0, }], }], }, // W Force { - Force: vec![ + force: vec![ // N Force { - Force: vec![], - Range: vec![1e-18], - Domain: vec![Component { - Component: vec![], - Composition: vec![], - Property: vec![Property { - Name: Ms, - Value: 1e-13, + force: vec![], + range: vec![1e-18], + domain: vec![Component { + component: vec![], + composition: vec![], + property: vec![Property { + name: MS, + value: 1e-13, }], }], }, // C Force { - Force: vec![], - Range: vec![1e-18], - Domain: vec![Component { - Component: vec![], - Composition: vec![], - Property: vec![Property { - Name: Sp, - Value: 1e-13, + force: vec![], + range: vec![1e-18], + domain: vec![Component { + component: vec![], + composition: vec![], + property: vec![Property { + name: SP, + value: 1e-13, }], }], }, ], - Range: vec![], - Domain: vec![], + range: vec![], + domain: vec![], }, // G Force { - Force: vec![], - Range: vec![f64::MAX], - Domain: vec![Component { - Component: vec![], - Composition: vec![], - Property: vec![Property { - Name: Ms, - Value: 1e-41, + force: vec![], + range: vec![f64::MAX], + domain: vec![Component { + component: vec![], + composition: vec![], + property: vec![Property { + name: MS, + value: 1e-41, }], }], }, ], - Range: vec![], - Domain: vec![], + range: vec![], + domain: vec![], }; } + +// pub fn add_particle(anom: &mut Anomaly, position: [f32; 3], properties: Vec) { +// anom.anomaly.push(particle(position, properties)); +// } diff --git a/src/display_mods.rs b/src/display_mods.rs index 1f95166..ed242f5 100644 --- a/src/display_mods.rs +++ b/src/display_mods.rs @@ -1,6 +1,5 @@ use std::f32::consts::PI; -use std::thread; -use std::time::{Duration, SystemTime}; +use std::time::SystemTime; pub trait Groupable { fn group_with_nothing(&self) -> String; @@ -26,40 +25,6 @@ pub fn record_nanos() -> u128 { .as_nanos(); } -pub fn wait_one_millis_and_micros_and_nanos() { - let tsn = Duration::from_nanos(1); - // Print text to the console. - - thread::sleep(tsn); - - let tsn2 = Duration::from_micros(1); - // Print text to the console. - - thread::sleep(tsn2); - - let tsn3 = Duration::from_millis(1); - // Print text to the console. - - thread::sleep(tsn3); -} - -pub fn wait_for_a_minute() { - let tsn3 = Duration::from_secs(60); - // Print text to the console. - - thread::sleep(tsn3); -} - -pub fn display_time_elapsed_nice(recorded_start: u128) -> u128 { - let current_time = record_nanos(); - - println!( - "Nanoseconds elapsed since last timestamp: {}", - (current_time - recorded_start).group_with_nothing() - ); // this is great - return current_time; -} - pub fn oclock() -> f32 { let now = SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) diff --git a/src/f32_3.rs b/src/f32_3.rs index f4dc989..8c5dab6 100644 --- a/src/f32_3.rs +++ b/src/f32_3.rs @@ -95,29 +95,6 @@ pub fn dot_product(a: [f32; 3], b: [f32; 3]) -> f32 { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } -pub fn angle_of(c: [f32; 3], x: [f32; 3], r: [f32; 3]) -> f32 { - // angle of point x compared to center and common random comparison vector - let vector = find_points_normal(x, c); - let vl = vector_length(vector); - - if vl == 0.0 { - return 0.0; - } - - let mut angle_of = dot_product(vector, r) / (vl * vector_length(r)); - - if angle_of > 1.0 { - angle_of = 1.0; - } - - if angle_of < -1.0 { - angle_of = -1.0; - } - - let angle = angle_of.acos(); - return angle; -} - pub fn angle_360_of(c: [f32; 3], x: [f32; 3], r: [f32; 3], norm: [f32; 3]) -> f32 { let diff = sbtr_f32_3(c, x); if vector_length(diff) == 0.0 { diff --git a/src/magma_ocean.rs b/src/magma_ocean.rs index 91685bd..898f990 100644 --- a/src/magma_ocean.rs +++ b/src/magma_ocean.rs @@ -1,22 +1,16 @@ use rand::Rng; -use std::thread; -use std::time::Duration; - -use crate::positions::{create_points_on_cross_section, sort_positions_by_angle, Normal, Position}; use crate::f32_3::{ angle_360_of, angular_difference, average_f32_3, dd_f32_3, find_points_normal, gen_f32_3, gen_rthgnl_f32_3, mltply_f32_3, nrmlz_f32_3, sbtr_f32_3, vector_length, }; - +use crate::positions::{create_points_on_cross_section, sort_positions_by_angle, Normal, Position}; use crate::shapes::{f32_3_dots_collinear, rotational_distance_function_sine, spherical_progress}; - use crate::u_modular::{modular_difference_in_range, modular_offset_in_range}; #[derive(Debug)] pub struct Magma { positions: Vec, - normals: Vec, indices: Vec, } @@ -27,18 +21,11 @@ pub struct Stone { pub indices: Vec, } -pub fn wait_for_a_minute() { - let tsn3 = Duration::from_secs(60); - // Print text to the console. - thread::sleep(tsn3); -} - pub fn magma(flow: u32, scale: f32) -> Magma { let mut rng = rand::thread_rng(); let mut lava_flow = Magma { positions: vec![], - normals: vec![], indices: vec![], }; @@ -267,9 +254,9 @@ pub fn find_indices_double_circle( let mut first_single_index = 0; let mut triangle_counter = 0; - let mut a_min = f32::MAX; - let mut a_min_dex = 0; - let mut k = 0; + let mut a_min; + let mut a_min_dex; + let mut k; let mut pointlike = false; for i in double_vertex_plane[0]..=double_vertex_plane[1] + 1 { diff --git a/src/main.rs b/src/main.rs index e61d23d..1eb88b0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,10 +6,10 @@ // at your option. All files in the project carrying such // notice may not be copied, modified, or distributed except // according to those terms. -#![allow(warnings)] // not today, erosion +//#![allow(warnings)] // not today, erosion mod display_mods; -use display_mods::{display_time_elapsed_nice, oclock, record_nanos, Groupable}; +use display_mods::{oclock, record_nanos, Groupable}; mod f32_3; use f32_3::gen_f32_3; @@ -27,7 +27,7 @@ mod magma_ocean; use magma_ocean::Stone; mod anomaly; -use anomaly::{add_particle_by, e, ls_f64, progress, q, ts_f64, view, Anomaly}; +use anomaly::{add_particle_by, e, progress, q, view, Anomaly, LS_F64, TS_F64}; mod moving_around; use moving_around::{ @@ -100,7 +100,7 @@ pub struct Bv { } fn main() { - let mut duration_since_epoch_nanos = record_nanos(); + let duration_since_epoch_nanos = record_nanos(); // Statements here are executed when the compiled binary is called. // let warning_test = "unused"; // results in CI warning @@ -115,9 +115,9 @@ fn main() { // let mut stone = petrify(magma(2, 10.0)); // let mut pebble = petrify(magma(2, 50.0)); let mut anom = Anomaly { - Anomaly: vec![], - Component: vec![], - Force: vec![], + anomaly: vec![], + component: vec![], + force: vec![], }; let k = 8; @@ -127,7 +127,7 @@ fn main() { &mut anom, e( gen_f32_3(0.0, 69.0, &mut rng), - mltply_f64_3(nrmlz_f64_3(gen_f64_3(0.0, 10.0, &mut rng)), ls_f64), + mltply_f64_3(nrmlz_f64_3(gen_f64_3(0.0, 10.0, &mut rng)), LS_F64), true, ), ); @@ -135,7 +135,7 @@ fn main() { &mut anom, q( gen_f32_3(0.0, 69.0, &mut rng), - mltply_f64_3(nrmlz_f64_3(gen_f64_3(0.0, 10.0, &mut rng)), ls_f64), + mltply_f64_3(nrmlz_f64_3(gen_f64_3(0.0, 10.0, &mut rng)), LS_F64), true, true, rng.gen_range(0..3), @@ -146,10 +146,10 @@ fn main() { let ocl = oclock().cos(); - ///|||\\\///|||\\\///|||\\\///|||\\\///|||\\\///|||\\\[ Main ]///|||\\\///|||\\\///|||\\\///|||\\\///|||\\\///|||\\\ - ///|||\\\ - ///|||\\\ - ///|||\\\ + //|||\\\///|||\\\///|||\\\///|||\\\///|||\\\///|||\\\[ Main ]///|||\\\///|||\\\///|||\\\///|||\\\///|||\\\///|||\\\ + //|||\\\ + //|||\\\ + //|||\\\ let event_loop = EventLoop::new().unwrap(); let library = VulkanLibrary::new().unwrap(); @@ -350,8 +350,6 @@ fn main() { let mut turning_up = false; let mut turning_down = false; - duration_since_epoch_nanos = display_time_elapsed_nice(duration_since_epoch_nanos); - let _modifiers = ModifiersState::default(); // Create a query pool for occlusion queries, with 3 slots. @@ -545,7 +543,7 @@ fn main() { // // move_positions(&mut stone.positions, [0.0, 0.0, 0.0]); - progress(&mut anom, ts_f64); + progress(&mut anom, TS_F64); let get = view(&mut anom); let mut bvs: Vec = vec![]; diff --git a/src/moving_around.rs b/src/moving_around.rs index 94b0bec..03a0fac 100644 --- a/src/moving_around.rs +++ b/src/moving_around.rs @@ -50,36 +50,6 @@ pub fn move_elevation( center.position = dd_f32_3(center.position, direction); } -pub fn move_in_x( - view_point: &mut Position, - center: &mut Position, - _up_direction: &mut Position, - rate: f32, -) { - view_point.position[0] = view_point.position[0] + rate; - center.position[0] = center.position[0] + rate; -} - -pub fn move_in_y( - view_point: &mut Position, - center: &mut Position, - _up_direction: &mut Position, - rate: f32, -) { - view_point.position[1] = view_point.position[1] + rate; - center.position[1] = center.position[1] + rate; -} - -pub fn move_in_z( - view_point: &mut Position, - center: &mut Position, - _up_direction: &mut Position, - rate: f32, -) { - view_point.position[2] = view_point.position[2] + rate; - center.position[2] = center.position[2] + rate; -} - pub fn rotate_up( view_point: &mut Position, center: &mut Position, diff --git a/src/unused.rs.warning b/src/unused.rs.warning new file mode 100644 index 0000000..ed9e79d --- /dev/null +++ b/src/unused.rs.warning @@ -0,0 +1,42 @@ +pub fn angle_of(c: [f32; 3], x: [f32; 3], r: [f32; 3]) -> f32 { + // angle of point x compared to center and common random comparison vector + let vector = find_points_normal(x, c); + let vl = vector_length(vector); + + if vl == 0.0 { + return 0.0; + } + + let mut angle_of = dot_product(vector, r) / (vl * vector_length(r)); + + if angle_of > 1.0 { + angle_of = 1.0; + } + + if angle_of < -1.0 { + angle_of = -1.0; + } + + let angle = angle_of.acos(); + return angle; +} + +pub fn add_particle(anom: &mut Anomaly, position: [f32; 3], properties: Vec) { + anom.anomaly.push(particle(position, properties)); +} + +pub fn wait_for_a_minute() { + let tsn3 = Duration::from_secs(60); + // Print text to the console. + thread::sleep(tsn3); +} + +pub fn display_time_elapsed_nice(recorded_start: u128) -> u128 { + let current_time = record_nanos(); + + println!( + "Nanoseconds elapsed since last timestamp: {}", + (current_time - recorded_start).group_with_nothing() + ); // this is great + return current_time; +}