diff --git a/chronicl.dt b/chronicl.dt index c24b6ae..72f523f 100644 --- a/chronicl.dt +++ b/chronicl.dt @@ -1 +1 @@ -38 \ No newline at end of file +39 \ No newline at end of file diff --git a/featuring.dt b/featuring.dt index c24b6ae..72f523f 100644 --- a/featuring.dt +++ b/featuring.dt @@ -1 +1 @@ -38 \ No newline at end of file +39 \ No newline at end of file diff --git a/ohio.note b/ohio.note index 9e79be3..46eb8b3 100644 --- a/ohio.note +++ b/ohio.note @@ -37,3 +37,4 @@ 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:: Year::2024::|::Month::03::|::Day::28::|::Hour::14::|::Minute::38::|::Second::10:: +Year::2024::|::Month::03::|::Day::31::|::Hour::16::|::Minute::02::|::Second::32:: diff --git a/src/anomaly.rs b/src/anomaly.rs index af1e13c..7b9ed5b 100644 --- a/src/anomaly.rs +++ b/src/anomaly.rs @@ -1,10 +1,13 @@ // experimental generic composite reductive approximation outline +use rand::rngs::ThreadRng; use std::sync::mpsc; use std::thread; use crate::f32_3::dd_f32_3; use crate::f64_3::mltply_f64_3; +use crate::gen_f64_3; use crate::magma_ocean::{magma, petrify, Stone}; +use crate::nrmlz_f64_3; use crate::positions::move_positions; pub static TS_F64: f64 = 5.391247 * 1e-44; @@ -50,13 +53,102 @@ pub fn interact(anom: &mut Anomaly) { } }); - component_interact(anom); + let mut rng = rand::thread_rng(); + + for i in 0..anom.anomaly.len() { + for j in 0..anom.anomaly.len() { + let (e, f) = if i < j { + // `i` is in the left half + let (left, right) = anom.anomaly.split_at_mut(j); + (&mut left[i], &mut right[0]) + } else if i == j { + // cannot obtain two mutable references to the + // same element + continue; + } else { + // `i` is in the right half + let (left, right) = anom.anomaly.split_at_mut(i); + (&mut right[0], &mut left[j]) + }; + anomaly_2_interact(e, f, &mut rng); + } + } + + component_interact(anom, &mut rng); +} + +pub fn anomaly_2_interact(a: &mut Anomaly, b: &mut Anomaly, mut rng: &mut ThreadRng) { + for i in a.anomaly.iter_mut() { + for j in b.anomaly.iter_mut() { + anomaly_2_interact(i, j, &mut rng); + } + } + + for df in &a.force { + for i in 0..a.component.len() { + for j in 0..b.component.len() { + component_2_interact(df, &mut a.component[i], &mut b.component[j], &mut rng); + } + } + } +} + +pub fn component_interact(_anom: &mut Anomaly, rng: &mut ThreadRng) { + for df in &_anom.force { + for i in 0.._anom.component.len() { + for j in 0.._anom.component.len() { + let (e, f) = if i < j { + // `i` is in the left half + let (left, right) = _anom.component.split_at_mut(j); + (&mut left[i], &mut right[0]) + } else if i == j { + // cannot obtain two mutable references to the + // same element + continue; + } else { + // `i` is in the right half + let (left, right) = _anom.component.split_at_mut(i); + (&mut right[0], &mut left[j]) + }; + component_2_interact(df, e, f, rng); + } + } + } +} + +pub fn component_2_interact( + df: &Force, + a: &mut Component, + b: &mut Component, + mut rng: &mut ThreadRng, +) { + for i in a.component.iter_mut() { + for j in b.component.iter_mut() { + component_2_interact(df, i, j, &mut rng); + } + } + + force_apply(df, a, b, &mut rng); } -pub fn component_interact(_anom: &mut Anomaly) { - // for f in &anom.force { +pub fn force_apply(_f: &Force, a: &mut Component, b: &mut Component, mut rng: &mut ThreadRng) { + // a1 = component_property(a, IN0); + // a2 = component_property(a, IN1); + // a3 = component_property(a, IN2); // - // } + // b1 = component_property(b, IN0); + // b2 = component_property(b, IN1); + // b3 = component_property(b, IN2); + + set_inertia( + mltply_f64_3(nrmlz_f64_3(gen_f64_3(0.0, 10.0, &mut rng)), LS_F64), + a, + ); + + set_inertia( + mltply_f64_3(nrmlz_f64_3(gen_f64_3(0.0, 10.0, &mut rng)), LS_F64), + b, + ); } pub fn progress(anom: &mut Anomaly, time: f64) { @@ -74,6 +166,27 @@ pub fn progress(anom: &mut Anomaly, time: f64) { } }); + let mut rng = rand::thread_rng(); + + for i in 0..anom.anomaly.len() { + for j in 0..anom.anomaly.len() { + let (e, f) = if i < j { + // `i` is in the left half + let (left, right) = anom.anomaly.split_at_mut(j); + (&mut left[i], &mut right[0]) + } else if i == j { + // cannot obtain two mutable references to the + // same element + continue; + } else { + // `i` is in the right half + let (left, right) = anom.anomaly.split_at_mut(i); + (&mut right[0], &mut left[j]) + }; + anomaly_2_interact(e, f, &mut rng); + } + } + let steps = (time / TS_F64) as u64; for _ in 0..steps { thread::scope(|s| { @@ -101,6 +214,14 @@ pub fn component_property(component: &mut Component, name: f64) -> f64 { return prop[0].value; } +pub fn set_component_property(n: f64, s: f64, component: &mut Component) { + for p in component.property.iter_mut() { + if n == p.name { + *p = Property { name: n, value: s }; + } + } +} + pub fn component_progress(component: &mut Component, time: f64) { for mut c in component.component.iter_mut() { component_progress(&mut c, time); @@ -195,6 +316,12 @@ pub fn particle(position: [f32; 3], properties: Vec) -> Anomaly { // future ref example +pub fn set_inertia(in0: [f64; 3], c: &mut Component) { + set_component_property(IN0, in0[0], c); + set_component_property(IN1, in0[1], c); + set_component_property(IN2, in0[2], c); +} + static EC: f64 = 313.0; static SP: f64 = 591.0; static MS: f64 = 343.0; diff --git a/src/magma_ocean.rs b/src/magma_ocean.rs index 898f990..e9c9a73 100644 --- a/src/magma_ocean.rs +++ b/src/magma_ocean.rs @@ -65,8 +65,8 @@ pub fn petrify(flow: Magma) -> Stone { let mut rng = rand::thread_rng(); let points_diff = sbtr_f32_3(flow.positions[1].position, flow.positions[0].position); let planes_normal: [f32; 3] = nrmlz_f32_3(points_diff); - let planes_number = rng.gen_range(4..32); - let max_points = rng.gen_range(4.0..32.0); + let planes_number = 24; // rng.gen_range(40..42); + let max_points = 24.0; // rng.gen_range(40.0..42.0); let mut points_of_plane: u32 = 3; let reference_orthogonal = gen_rthgnl_f32_3(planes_normal, &mut rng); diff --git a/src/main.rs b/src/main.rs index c473ba3..5a445e5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ // 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::{oclock, record_nanos, Groupable}; @@ -120,7 +120,7 @@ fn main() { force: vec![], }; - let k = 8; + let k = 20; for _ in 0..k { add_particle_by( @@ -356,7 +356,7 @@ fn main() { let query_pool = QueryPool::new( device.clone(), QueryPoolCreateInfo { - query_count: 3, + query_count: 60, ..QueryPoolCreateInfo::query_type(QueryType::Occlusion) }, )