diff --git a/chronicl.dt b/chronicl.dt index 368f89c..d99e90e 100644 --- a/chronicl.dt +++ b/chronicl.dt @@ -1 +1 @@ -28 \ No newline at end of file +29 \ No newline at end of file diff --git a/featuring.dt b/featuring.dt index 368f89c..d99e90e 100644 --- a/featuring.dt +++ b/featuring.dt @@ -1 +1 @@ -28 \ No newline at end of file +29 \ No newline at end of file diff --git a/ohio.note b/ohio.note index 606dd8f..40244aa 100644 --- a/ohio.note +++ b/ohio.note @@ -27,3 +27,4 @@ Year::2024::|::Month::03::|::Day::19::|::Hour::19::|::Minute::40::|::Second::53: Year::2024::|::Month::03::|::Day::20::|::Hour::17::|::Minute::16::|::Second::54:: Year::2024::|::Month::03::|::Day::21::|::Hour::14::|::Minute::51::|::Second::35:: Year::2024::|::Month::03::|::Day::22::|::Hour::16::|::Minute::32::|::Second::41:: +Year::2024::|::Month::03::|::Day::24::|::Hour::19::|::Minute::16::|::Second::53:: diff --git a/src/f32_3.rs b/src/f32_3.rs index 778e551..d6e2ded 100644 --- a/src/f32_3.rs +++ b/src/f32_3.rs @@ -98,7 +98,13 @@ pub fn dot_product(a: [f32; 3], b: [f32; 3]) -> f32 { 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 mut angle_of = (dot_product(vector, r) / (vector_length(vector) * vector_length(r))); + 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; @@ -114,6 +120,10 @@ pub fn angle_of(c: [f32; 3], x: [f32; 3], r: [f32; 3]) -> f32 { 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 { + return 0.0; + } + let vector = nrmlz_f32_3(diff); let mut angle_of = (dot_product(vector, r) / (vector_length(vector) * vector_length(r))); diff --git a/src/magma_ocean.rs b/src/magma_ocean.rs index 4dbd78c..ffe97a7 100644 --- a/src/magma_ocean.rs +++ b/src/magma_ocean.rs @@ -13,7 +13,7 @@ use crate::f32_3::{ mltply_f32_3, nrmlz_f32_3, sbtr_f32_3, vector_length, }; -use crate::shapes::{f32_3_dots_collinear, rotational_distance_function_sine}; +use crate::shapes::{f32_3_dots_collinear, rotational_distance_function_sine, spherical_progress}; use crate::u_modular::{ modular_difference, modular_difference_in_range, modular_offset, modular_offset_in_range, @@ -102,11 +102,12 @@ pub fn petrify(flow: Magma) -> Stone { // println!("plane: {:#?}", plane_point); // vector_length(points_diff) / 2.0 * (PI * pln as f32 / planes_points.len() as f32).sin() - let d = (vector_length(points_diff) / 2.0) - * (pln as f32 - planes_points.len() as f32 / 2.0).abs() - / (planes_points.len() as f32 / 2.0); let rotational_arguments_vector = vec![ - ((vector_length(points_diff) / 2.0).powi(2) - d.powi(2)).sqrt(), + spherical_progress( + vector_length(points_diff), + pln as f32, + planes_number as f32 - 1.0, + ), 0.0, 0.0, 0.0, @@ -131,6 +132,8 @@ pub fn petrify(flow: Magma) -> Stone { &mut rng, ); + points_of_plane = plane.positions.len() as u32; + sort_positions_by_angle( *plane_point, reference_orthogonal, @@ -261,6 +264,7 @@ pub fn find_indices_double_circle( let mut a_min = f32::MAX; let mut a_min_dex = 0; let mut k = 0; + let mut pointlike = false; for i in double_vertex_plane[0]..=double_vertex_plane[1] + 1 { a_min = f32::MAX; @@ -270,7 +274,6 @@ pub fn find_indices_double_circle( if k > double_vertex_plane[1] { k = double_vertex_plane[0]; } - // take the points, // get their vector from the circle's average point // translate this distance to the plane point on the interplane-axis ("normal" points) @@ -321,6 +324,7 @@ pub fn find_indices_double_circle( planes_normal, ), ); + if dist < a_min { a_min = dist; a_min_dex = j; @@ -332,36 +336,43 @@ pub fn find_indices_double_circle( triangle_counter = triangle_counter + 1; } else { a_min_dex = first_single_index; + if a_min_dex == index_single_saved && triangle_counter == points_of_double_plane { + pointlike = true; + } } if index_set { let mut running_index = index_single_saved; - if index_single_saved != a_min_dex { - for l in 1..=modular_difference_in_range( - index_single_saved, - a_min_dex, + let mut loop_for = modular_difference_in_range( + index_single_saved, + a_min_dex, + single_vertex_plane[0], + single_vertex_plane[1], + ); + + if pointlike { + loop_for = single_vertex_plane[1] - single_vertex_plane[0] + 1; + } + + for l in 1..=loop_for { + stone.indices.push(index_double_saved); + stone.indices.push(running_index); + stone.indices.push(modular_offset_in_range( + running_index, + 1, single_vertex_plane[0], single_vertex_plane[1], - ) { - stone.indices.push(index_double_saved); - stone.indices.push(running_index); - stone.indices.push(modular_offset_in_range( - running_index, - 1, - single_vertex_plane[0], - single_vertex_plane[1], - )); - - triangle_counter = triangle_counter + 1; - - running_index = modular_offset_in_range( - running_index, - 1, - single_vertex_plane[0], - single_vertex_plane[1], - ); - } + )); + + triangle_counter = triangle_counter + 1; + + running_index = modular_offset_in_range( + running_index, + 1, + single_vertex_plane[0], + single_vertex_plane[1], + ); } } else { first_single_index = a_min_dex; @@ -397,14 +408,6 @@ pub fn find_indices_double_circle( if debug { println!("Further Info 1{:#?}", single_vertex_plane,); - println!("Further Info 2{:#?}", single_plane_point,); - - println!("Further Info 3{:#?}", double_vertex_plane,); - - println!("Further Info 4{:#?}", double_plane_point,); - - println!("Further Info 5{:#?}", reference_orthogonal,); - - println!("Further Info 6{:#?}", planes_normal,); + println!("Further Info 2{:#?}", double_vertex_plane,); } } diff --git a/src/main.rs b/src/main.rs index a719850..56e4d9e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -298,7 +298,7 @@ fn main() { //\\\|||/// //\\\|||///\\\|||///\\\|||///\\\|||///\\\|||///[ the end of setup ]\\\|||///\\\|||///\\\|||///\\\|||///\\\|||///\\\|||/// - let mut rot_static = false; + let mut rot_static = true; let mut view_point = Position { position: [0.0, -1.0, 1.0], @@ -513,23 +513,9 @@ fn main() { // simulation - move_positions( - &mut pebble.positions, - [ - rng.gen_range(-100.6..100.6), - rng.gen_range(-100.6..100.6), - rng.gen_range(-100.6..100.6), - ], - ); - - move_positions( - &mut stone.positions, - [ - rng.gen_range(-1.6..1.6), - rng.gen_range(-1.6..1.6), - rng.gen_range(-1.6..1.6), - ], - ); + move_positions(&mut pebble.positions, [0.0, 0.0, 0.0]); + + move_positions(&mut stone.positions, [0.0, 0.0, 0.0]); let (vertex_buffer, normals_buffer, index_buffer) = load_buffers_short(&mut stone, memory_allocator.clone()); @@ -608,15 +594,6 @@ fn main() { proj: proj.into(), }; - let rec = record_nanos(); - - if (rec > duration_since_epoch_nanos + 1000000000) { - println!("uniform 0 : {:#?}", uniform_data.world); - println!("uniform 1 : {:#?}", uniform_data.view); - println!("uniform 2 : {:#?}", uniform_data.proj); - duration_since_epoch_nanos = rec; - } - let subbuffer = uniform_buffer.allocate_sized().unwrap(); *subbuffer.write().unwrap() = uniform_data; diff --git a/src/shapes.rs b/src/shapes.rs index fa1414d..0067c0a 100644 --- a/src/shapes.rs +++ b/src/shapes.rs @@ -30,3 +30,9 @@ pub fn rotational_distance_function_sine( ) -> f32 { return c_arg[0] + c_arg[1] * (c_arg[2] + x * c_arg[3]).sin(); } + +pub fn spherical_progress(points_diff: f32, pln: f32, planes_points: f32) -> f32 { + let d = (points_diff / 2.0) * (pln - planes_points / 2.0).abs() / (planes_points / 2.0); + let f = ((points_diff / 2.0).powi(2) - d.powi(2)).sqrt(); + return f; +}