From 01261aed91d4b4dae8f898b904a29720ddb5cf9a Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Tue, 21 Jan 2025 18:04:21 -0800 Subject: [PATCH] Write kaleidocycle nudge in uniform coordinates In the previous commit, the nudge was written in standard coordinates, so the example shouldn't have worked. However, by sheer dumb luck, the standard and uniform coordinates match for this particular nudge. In fact, the expression used before to get the standard coordinates may even produce equivalent floating point values as the expression used here to get the uniform coordinates. That would explain why the example prints exactly the same output in this commit. --- app-proto/examples/kaleidocycle.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/app-proto/examples/kaleidocycle.rs b/app-proto/examples/kaleidocycle.rs index effb226..3448b87 100644 --- a/app-proto/examples/kaleidocycle.rs +++ b/app-proto/examples/kaleidocycle.rs @@ -1,4 +1,4 @@ -use nalgebra::DMatrix; +use nalgebra::{DMatrix, DVector}; use std::{array, f64::consts::PI}; use dyna3::engine::{Q, point, realize_gram, PartialMatrix}; @@ -59,22 +59,13 @@ fn main() { println!("Loss: {}\n", history.scaled_loss.last().unwrap()); // find the kaleidocycle's twist motion + let up = DVector::from_column_slice(&[0.0, 0.0, 1.0, 0.0, 0.0]); + let down = -&up; let twist_motion: DMatrix<_> = (0..N_POINTS).step_by(4).flat_map( - |n| { - let up_field = { - DMatrix::from_column_slice(5, 5, &[ - 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 1.0, - 0.0, 0.0, 2.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0 - ]) - }; - [ - tangent.proj(&(&up_field * config.column(n)).as_view(), n), - tangent.proj(&(-&up_field * config.column(n+1)).as_view(), n+1) - ] - } + |n| [ + tangent.proj(&up.as_view(), n), + tangent.proj(&down.as_view(), n+1) + ] ).sum(); let normalization = 5.0 / twist_motion[(2, 0)]; print!("Twist motion:{}", normalization * twist_motion);