From 9f85ce560870fb5a3caff6af1b203da824d88240 Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Mon, 9 Dec 2024 15:58:45 -0800 Subject: [PATCH] Step elements geodesically instead of linearly This helps prevent small spheres from shrinking during deformations. --- app-proto/src/assembly.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app-proto/src/assembly.rs b/app-proto/src/assembly.rs index 77fbe94..24f9b93 100644 --- a/app-proto/src/assembly.rs +++ b/app-proto/src/assembly.rs @@ -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)); }); }