From da008fd09075e27e99e2a2d30a8826d26f701434 Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Sun, 10 Nov 2024 19:24:26 -0800 Subject: [PATCH] Write out `representation` in `Element` structure --- app-proto/src/add_remove.rs | 28 ++++++++++++++-------------- app-proto/src/assembly.rs | 8 ++++---- app-proto/src/display.rs | 4 +++- app-proto/src/outline.rs | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/app-proto/src/add_remove.rs b/app-proto/src/add_remove.rs index 92ae4be..6fee142 100644 --- a/app-proto/src/add_remove.rs +++ b/app-proto/src/add_remove.rs @@ -11,7 +11,7 @@ fn load_gen_assemb(assembly: &Assembly) { id: String::from("gemini_a"), label: String::from("Castor"), color: [1.00_f32, 0.25_f32, 0.00_f32], - rep: engine::sphere(0.5, 0.5, 0.0, 1.0), + representation: engine::sphere(0.5, 0.5, 0.0, 1.0), constraints: BTreeSet::default(), index: 0 } @@ -21,7 +21,7 @@ fn load_gen_assemb(assembly: &Assembly) { id: String::from("gemini_b"), label: String::from("Pollux"), color: [0.00_f32, 0.25_f32, 1.00_f32], - rep: engine::sphere(-0.5, -0.5, 0.0, 1.0), + representation: engine::sphere(-0.5, -0.5, 0.0, 1.0), constraints: BTreeSet::default(), index: 0 } @@ -31,7 +31,7 @@ fn load_gen_assemb(assembly: &Assembly) { id: String::from("ursa_major"), label: String::from("Ursa major"), color: [0.25_f32, 0.00_f32, 1.00_f32], - rep: engine::sphere(-0.5, 0.5, 0.0, 0.75), + representation: engine::sphere(-0.5, 0.5, 0.0, 0.75), constraints: BTreeSet::default(), index: 0 } @@ -41,7 +41,7 @@ fn load_gen_assemb(assembly: &Assembly) { id: String::from("ursa_minor"), label: String::from("Ursa minor"), color: [0.25_f32, 1.00_f32, 0.00_f32], - rep: engine::sphere(0.5, -0.5, 0.0, 0.5), + representation: engine::sphere(0.5, -0.5, 0.0, 0.5), constraints: BTreeSet::default(), index: 0 } @@ -51,7 +51,7 @@ fn load_gen_assemb(assembly: &Assembly) { id: String::from("moon_deimos"), label: String::from("Deimos"), color: [0.75_f32, 0.75_f32, 0.00_f32], - rep: engine::sphere(0.0, 0.15, 1.0, 0.25), + representation: engine::sphere(0.0, 0.15, 1.0, 0.25), constraints: BTreeSet::default(), index: 0 } @@ -61,7 +61,7 @@ fn load_gen_assemb(assembly: &Assembly) { id: String::from("moon_phobos"), label: String::from("Phobos"), color: [0.00_f32, 0.75_f32, 0.50_f32], - rep: engine::sphere(0.0, -0.15, -1.0, 0.25), + representation: engine::sphere(0.0, -0.15, -1.0, 0.25), constraints: BTreeSet::default(), index: 0 } @@ -76,7 +76,7 @@ fn load_low_curv_assemb(assembly: &Assembly) { id: "central".to_string(), label: "Central".to_string(), color: [0.75_f32, 0.75_f32, 0.75_f32], - rep: engine::sphere(0.0, 0.0, 0.0, 1.0), + representation: engine::sphere(0.0, 0.0, 0.0, 1.0), constraints: BTreeSet::default(), index: 0 } @@ -86,7 +86,7 @@ fn load_low_curv_assemb(assembly: &Assembly) { id: "assemb_plane".to_string(), label: "Assembly plane".to_string(), color: [0.75_f32, 0.75_f32, 0.75_f32], - rep: engine::sphere_with_offset(0.0, 0.0, 1.0, 0.0, 0.0), + representation: engine::sphere_with_offset(0.0, 0.0, 1.0, 0.0, 0.0), constraints: BTreeSet::default(), index: 0 } @@ -96,7 +96,7 @@ fn load_low_curv_assemb(assembly: &Assembly) { id: "side1".to_string(), label: "Side 1".to_string(), color: [1.00_f32, 0.00_f32, 0.25_f32], - rep: engine::sphere_with_offset(1.0, 0.0, 0.0, 1.0, 0.0), + representation: engine::sphere_with_offset(1.0, 0.0, 0.0, 1.0, 0.0), constraints: BTreeSet::default(), index: 0 } @@ -106,7 +106,7 @@ fn load_low_curv_assemb(assembly: &Assembly) { id: "side2".to_string(), label: "Side 2".to_string(), color: [0.25_f32, 1.00_f32, 0.00_f32], - rep: engine::sphere_with_offset(-0.5, a, 0.0, 1.0, 0.0), + representation: engine::sphere_with_offset(-0.5, a, 0.0, 1.0, 0.0), constraints: BTreeSet::default(), index: 0 } @@ -116,7 +116,7 @@ fn load_low_curv_assemb(assembly: &Assembly) { id: "side3".to_string(), label: "Side 3".to_string(), color: [0.00_f32, 0.25_f32, 1.00_f32], - rep: engine::sphere_with_offset(-0.5, -a, 0.0, 1.0, 0.0), + representation: engine::sphere_with_offset(-0.5, -a, 0.0, 1.0, 0.0), constraints: BTreeSet::default(), index: 0 } @@ -126,7 +126,7 @@ fn load_low_curv_assemb(assembly: &Assembly) { id: "corner1".to_string(), label: "Corner 1".to_string(), color: [0.75_f32, 0.75_f32, 0.75_f32], - rep: engine::sphere(-4.0/3.0, 0.0, 0.0, 1.0/3.0), + representation: engine::sphere(-4.0/3.0, 0.0, 0.0, 1.0/3.0), constraints: BTreeSet::default(), index: 0 } @@ -136,7 +136,7 @@ fn load_low_curv_assemb(assembly: &Assembly) { id: "corner2".to_string(), label: "Corner 2".to_string(), color: [0.75_f32, 0.75_f32, 0.75_f32], - rep: engine::sphere(2.0/3.0, -4.0/3.0 * a, 0.0, 1.0/3.0), + representation: engine::sphere(2.0/3.0, -4.0/3.0 * a, 0.0, 1.0/3.0), constraints: BTreeSet::default(), index: 0 } @@ -146,7 +146,7 @@ fn load_low_curv_assemb(assembly: &Assembly) { id: String::from("corner3"), label: String::from("Corner 3"), color: [0.75_f32, 0.75_f32, 0.75_f32], - rep: engine::sphere(2.0/3.0, 4.0/3.0 * a, 0.0, 1.0/3.0), + representation: engine::sphere(2.0/3.0, 4.0/3.0 * a, 0.0, 1.0/3.0), constraints: BTreeSet::default(), index: 0 } diff --git a/app-proto/src/assembly.rs b/app-proto/src/assembly.rs index 0970932..27774a1 100644 --- a/app-proto/src/assembly.rs +++ b/app-proto/src/assembly.rs @@ -12,7 +12,7 @@ pub struct Element { pub id: String, pub label: String, pub color: [f32; 3], - pub rep: DVector, + pub representation: DVector, pub constraints: BTreeSet, // internal properties, not reflected in any view @@ -86,7 +86,7 @@ impl Assembly { id: id, label: format!("Sphere {}", id_num), color: [0.75_f32, 0.75_f32, 0.75_f32], - rep: DVector::::from_column_slice(&[0.0, 0.0, 0.0, 0.5, -0.5]), + representation: DVector::::from_column_slice(&[0.0, 0.0, 0.0, 0.5, -0.5]), constraints: BTreeSet::default(), index: 0 } @@ -133,7 +133,7 @@ impl Assembly { for (_, elt) in elts { let index = elt.index; gram_to_be.push_sym(index, index, 1.0); - guess_to_be.set_column(index, &elt.rep); + guess_to_be.set_column(index, &elt.representation); } (gram_to_be, guess_to_be) @@ -177,7 +177,7 @@ impl Assembly { // read out the solution self.elements.update(|elts| { for (_, elt) in elts.iter_mut() { - elt.rep.set_column(0, &config.column(elt.index)); + elt.representation.set_column(0, &config.column(elt.index)); } }); } diff --git a/app-proto/src/display.rs b/app-proto/src/display.rs index c32b470..79199ec 100644 --- a/app-proto/src/display.rs +++ b/app-proto/src/display.rs @@ -297,7 +297,9 @@ pub fn Display() -> View { // get the assembly let elements = state.assembly.elements.get_clone(); let element_iter = (&elements).into_iter(); - let reps_world: Vec<_> = element_iter.clone().map(|(_, elt)| &assembly_to_world * &elt.rep).collect(); + let reps_world: Vec<_> = element_iter.clone().map( + |(_, elt)| &assembly_to_world * &elt.representation + ).collect(); let colors: Vec<_> = element_iter.clone().map(|(key, elt)| if state.selection.with(|sel| sel.contains(&key)) { elt.color.map(|ch| 0.2 + 0.8*ch) diff --git a/app-proto/src/outline.rs b/app-proto/src/outline.rs index 8edbe07..9ebf34d 100644 --- a/app-proto/src/outline.rs +++ b/app-proto/src/outline.rs @@ -72,7 +72,7 @@ pub fn Outline() -> View { } }); let label = elt.label.clone(); - let rep_components = elt.rep.iter().map(|u| { + let rep_components = elt.representation.iter().map(|u| { let u_coord = u.to_string().replace("-", "\u{2212}"); View::from(div().children(u_coord)) }).collect::>();