Add structures for element and assembly motions
This commit is contained in:
parent
90834fbb93
commit
4fd79b9e47
@ -119,6 +119,13 @@ pub struct Constraint {
|
||||
pub active: Signal<bool>
|
||||
}
|
||||
|
||||
pub struct ElementMotion<'a> {
|
||||
pub key: ElementKey,
|
||||
pub velocity: DVectorView<'a, f64>
|
||||
}
|
||||
|
||||
type AssemblyMotion<'a> = Vec<ElementMotion<'a>>;
|
||||
|
||||
// a complete, view-independent description of an assembly
|
||||
#[derive(Clone)]
|
||||
pub struct Assembly {
|
||||
@ -290,7 +297,7 @@ impl Assembly {
|
||||
|
||||
// --- deformation ---
|
||||
|
||||
pub fn deform(&self, element_motions: Vec<(ElementKey, DVectorView<f64>)>) {
|
||||
pub fn deform(&self, motion: AssemblyMotion) {
|
||||
/* KLUDGE */
|
||||
// when the tangent space is zero, we currently need to avoid calling
|
||||
// its `proj` method, because it will panic rather than returning zero.
|
||||
@ -307,9 +314,9 @@ impl Assembly {
|
||||
|
||||
// project the element motions onto the tangent space of the solution
|
||||
// variety, and sum them to get a deformation of the whole assembly
|
||||
for (elt_key, elt_motion) in element_motions {
|
||||
let column_index = self.elements.with(|elts| elts[elt_key].column_index);
|
||||
motion_proj += self.tangent.with(|tan| tan.proj(&elt_motion, column_index));
|
||||
for elt_motion in motion {
|
||||
let column_index = self.elements.with(|elts| elts[elt_motion.key].column_index);
|
||||
motion_proj += self.tangent.with(|tan| tan.proj(&elt_motion.velocity, column_index));
|
||||
}
|
||||
|
||||
// step each element along the mass shell geodesic that matches its
|
||||
|
@ -14,7 +14,7 @@ use web_sys::{
|
||||
wasm_bindgen::{JsCast, JsValue}
|
||||
};
|
||||
|
||||
use crate::{AppState, assembly::ElementKey};
|
||||
use crate::{AppState, assembly::{ElementKey, ElementMotion}};
|
||||
|
||||
fn compile_shader(
|
||||
context: &WebGl2RenderingContext,
|
||||
@ -341,7 +341,14 @@ pub fn Display() -> View {
|
||||
])
|
||||
};
|
||||
let elt_motion: DVector<f64> = time_step * TRANSLATION_SPEED * vel_field * rep;
|
||||
assembly_for_raf.deform(vec![(sel, elt_motion.as_view())]);
|
||||
assembly_for_raf.deform(
|
||||
vec![
|
||||
ElementMotion {
|
||||
key: sel,
|
||||
velocity: elt_motion.as_view()
|
||||
}
|
||||
]
|
||||
);
|
||||
scene_changed.set(true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user