Step elements geodesically instead of linearly

This helps prevent small spheres from shrinking during deformations.
This commit is contained in:
Aaron Fenyes 2024-12-09 15:58:45 -08:00
parent 2906571f32
commit 9f85ce5608

View File

@ -5,7 +5,7 @@ use std::{collections::BTreeSet, sync::atomic::{AtomicU64, Ordering}};
use sycamore::prelude::*;
use web_sys::{console, wasm_bindgen::JsValue}; /* DEBUG */
use crate::engine::{realize_gram, ConfigSubspace, PartialMatrix};
use crate::engine::{realize_gram, ConfigSubspace, PartialMatrix, Q};
// the types of the keys we use to access an assembly's elements and constraints
pub type ElementKey = usize;
@ -312,12 +312,16 @@ impl Assembly {
motion_proj += self.tangent.with(|tan| tan.proj(&elt_motion, column_index));
}
// step the configuration linearly along the tangent space of the
// solution variety
// step each element along the mass shell geodesic that matches its
// velocity in the deformation found above
/* KLUDGE */
// since our test assemblies only involve spheres, we assume that every
// element is on the 1 mass shell
for (_, elt) in self.elements.get_clone_untracked() {
elt.representation.update_silent(|rep| {
let rep_next = &*rep + motion_proj.column(elt.column_index);
rep.set_column(0, &rep_next);
let normalizer = rep_next.dot(&(&*Q * &rep_next));
rep.set_column(0, &(rep_next / normalizer));
});
}