forked from glen/dyna3
Compare commits
3 commits
uniform-pr
...
main
Author | SHA1 | Date | |
---|---|---|---|
46324fecc6 | |||
25017176fd | |||
817a446fad |
2 changed files with 24 additions and 19 deletions
|
@ -5,7 +5,7 @@ use std::{collections::BTreeSet, sync::atomic::{AtomicU64, Ordering}};
|
||||||
use sycamore::prelude::*;
|
use sycamore::prelude::*;
|
||||||
use web_sys::{console, wasm_bindgen::JsValue}; /* DEBUG */
|
use web_sys::{console, wasm_bindgen::JsValue}; /* DEBUG */
|
||||||
|
|
||||||
use crate::engine::{realize_gram, local_unif_to_std, ConfigSubspace, PartialMatrix, Q};
|
use crate::engine::{realize_gram, local_unif_to_std, ConfigSubspace, PartialMatrix};
|
||||||
|
|
||||||
// the types of the keys we use to access an assembly's elements and constraints
|
// the types of the keys we use to access an assembly's elements and constraints
|
||||||
pub type ElementKey = usize;
|
pub type ElementKey = usize;
|
||||||
|
@ -371,8 +371,8 @@ impl Assembly {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// step each element along the mass shell geodesic that matches its
|
// step the assembly along the deformation. this changes the elements'
|
||||||
// velocity in the deformation found above
|
// normalizations, so we restore those afterward
|
||||||
/* KLUDGE */
|
/* KLUDGE */
|
||||||
// since our test assemblies only include spheres, we assume that every
|
// since our test assemblies only include spheres, we assume that every
|
||||||
// element is on the 1 mass shell
|
// element is on the 1 mass shell
|
||||||
|
@ -380,9 +380,16 @@ impl Assembly {
|
||||||
elt.representation.update_silent(|rep| {
|
elt.representation.update_silent(|rep| {
|
||||||
match elt.column_index {
|
match elt.column_index {
|
||||||
Some(column_index) => {
|
Some(column_index) => {
|
||||||
let rep_next = &*rep + motion_proj.column(column_index);
|
// step the assembly along the deformation
|
||||||
let normalizer = rep_next.dot(&(&*Q * &rep_next));
|
*rep += motion_proj.column(column_index);
|
||||||
rep.set_column(0, &(rep_next / normalizer));
|
|
||||||
|
// restore normalization by contracting toward the last
|
||||||
|
// coordinate axis
|
||||||
|
let q_sp = rep.fixed_rows::<3>(0).norm_squared();
|
||||||
|
let half_q_lt = -2.0 * rep[3] * rep[4];
|
||||||
|
let half_q_lt_sq = half_q_lt * half_q_lt;
|
||||||
|
let scaling = half_q_lt + (q_sp + half_q_lt_sq).sqrt();
|
||||||
|
rep.fixed_rows_mut::<4>(0).scale_mut(1.0 / scaling);
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
console::log_1(&JsValue::from(
|
console::log_1(&JsValue::from(
|
||||||
|
|
|
@ -64,11 +64,16 @@ fn ElementOutlineItem(key: ElementKey, element: assembly::Element) -> View {
|
||||||
move |sel| if sel.contains(&key) { "selected" } else { "" }
|
move |sel| if sel.contains(&key) { "selected" } else { "" }
|
||||||
);
|
);
|
||||||
let label = element.label.clone();
|
let label = element.label.clone();
|
||||||
let rep_components = element.representation.map(
|
let rep_components = move || {
|
||||||
|rep| rep.iter().map(
|
element.representation.with(
|
||||||
|u| format!("{:.3}", u).replace("-", "\u{2212}")
|
|rep| rep.iter().map(
|
||||||
).collect()
|
|u| {
|
||||||
);
|
let u_str = format!("{:.3}", u).replace("-", "\u{2212}");
|
||||||
|
view! { div { (u_str) } }
|
||||||
|
}
|
||||||
|
).collect::<Vec<_>>()
|
||||||
|
)
|
||||||
|
};
|
||||||
let constrained = element.constraints.map(|csts| csts.len() > 0);
|
let constrained = element.constraints.map(|csts| csts.len() > 0);
|
||||||
let constraint_list = element.constraints.map(
|
let constraint_list = element.constraints.map(
|
||||||
|csts| csts.clone().into_iter().collect()
|
|csts| csts.clone().into_iter().collect()
|
||||||
|
@ -129,14 +134,7 @@ fn ElementOutlineItem(key: ElementKey, element: assembly::Element) -> View {
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
div(class="element-label") { (label) }
|
div(class="element-label") { (label) }
|
||||||
div(class="element-representation") {
|
div(class="element-representation") { (rep_components) }
|
||||||
Indexed(
|
|
||||||
list=rep_components,
|
|
||||||
view=|coord_str| view! {
|
|
||||||
div { (coord_str) }
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
div(class="status")
|
div(class="status")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue