dyna3/app-proto/examples/three-spheres.rs
Aaron Fenyes 679c421d04 Encapsulate realization results
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.
2025-06-26 22:42:02 -07:00

34 lines
No EOL
947 B
Rust

mod common;
use common::{
print_gram_matrix,
print_loss_history,
print_realization_diagnostics,
print_title
};
use dyna3::engine::{realize_gram, sphere, ConstraintProblem, Realization};
fn main() {
let mut problem = ConstraintProblem::from_guess({
let a: f64 = 0.75_f64.sqrt();
&[
sphere(1.0, 0.0, 0.0, 1.0),
sphere(-0.5, a, 0.0, 1.0),
sphere(-0.5, -a, 0.0, 1.0)
]
});
for j in 0..3 {
for k in j..3 {
problem.gram.push_sym(j, k, if j == k { 1.0 } else { -1.0 });
}
}
let realization_result = realize_gram(
&problem, 1.0e-12, 0.5, 0.9, 1.1, 200, 110
);
print_title("Three spheres");
print_realization_diagnostics(&realization_result);
if let Ok(Realization{ config, .. }) = realization_result.result {
print_gram_matrix(&config);
}
print_loss_history(&realization_result.history);
}