forked from StudioInfinity/dyna3

In the process, spruce up our realization diagnostics logging and factor out some of the repetitive code in the examples, because we're already changing those parts of the code to adapt them to the new encapsulation. This commit changes the example output format. I've checked by hand that the output is rearranged but not meaningfully changed.
37 lines
No EOL
1.2 KiB
Rust
37 lines
No EOL
1.2 KiB
Rust
mod common;
|
|
|
|
use nalgebra::{DMatrix, DVector};
|
|
|
|
use common::{
|
|
print_config,
|
|
print_gram_matrix,
|
|
print_realization_diagnostics,
|
|
print_title
|
|
};
|
|
use dyna3::engine::{Realization, examples::realize_kaleidocycle};
|
|
|
|
fn main() {
|
|
const SCALED_TOL: f64 = 1.0e-12;
|
|
let realization_result = realize_kaleidocycle(SCALED_TOL);
|
|
print_title("Kaleidocycle");
|
|
print_realization_diagnostics(&realization_result);
|
|
if let Ok(Realization { config, tangent }) = realization_result.result {
|
|
// print the completed Gram matrix and the realized configuration
|
|
print_gram_matrix(&config);
|
|
print_config(&config);
|
|
|
|
// find the kaleidocycle's twist motion by projecting onto the tangent
|
|
// space
|
|
const N_POINTS: usize = 12;
|
|
let up = DVector::from_column_slice(&[0.0, 0.0, 1.0, 0.0]);
|
|
let down = -&up;
|
|
let twist_motion: DMatrix<_> = (0..N_POINTS).step_by(4).flat_map(
|
|
|n| [
|
|
tangent.proj(&up.as_view(), n),
|
|
tangent.proj(&down.as_view(), n+1)
|
|
]
|
|
).sum();
|
|
let normalization = 5.0 / twist_motion[(2, 0)];
|
|
println!("\nTwist motion:{}", (normalization * twist_motion).to_string().trim_end());
|
|
}
|
|
} |