2025-07-18 10:59:41 -07:00
|
|
|
#[path = "common/print.rs"]
|
|
|
|
mod print;
|
2025-06-09 22:21:34 -07:00
|
|
|
|
|
|
|
use dyna3::engine::{realize_gram, sphere, ConstraintProblem, Realization};
|
2024-11-26 00:32:50 +00:00
|
|
|
|
|
|
|
fn main() {
|
2025-04-21 23:40:42 +00:00
|
|
|
let mut problem = ConstraintProblem::from_guess({
|
2024-11-26 00:32:50 +00:00
|
|
|
let a: f64 = 0.75_f64.sqrt();
|
2025-04-21 23:40:42 +00:00
|
|
|
&[
|
2024-11-26 00:32:50 +00:00
|
|
|
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)
|
2025-04-21 23:40:42 +00:00
|
|
|
]
|
|
|
|
});
|
|
|
|
for j in 0..3 {
|
|
|
|
for k in j..3 {
|
|
|
|
problem.gram.push_sym(j, k, if j == k { 1.0 } else { -1.0 });
|
|
|
|
}
|
|
|
|
}
|
2025-06-09 22:21:34 -07:00
|
|
|
let realization_result = realize_gram(
|
2025-04-21 23:40:42 +00:00
|
|
|
&problem, 1.0e-12, 0.5, 0.9, 1.1, 200, 110
|
2024-11-26 00:32:50 +00:00
|
|
|
);
|
2025-07-18 10:59:41 -07:00
|
|
|
print::title("Three spheres");
|
|
|
|
print::realization_diagnostics(&realization_result);
|
2025-06-09 22:21:34 -07:00
|
|
|
if let Ok(Realization{ config, .. }) = realization_result.result {
|
2025-07-18 10:59:41 -07:00
|
|
|
print::gram_matrix(&config);
|
2024-11-26 00:32:50 +00:00
|
|
|
}
|
2025-07-18 10:59:41 -07:00
|
|
|
print::loss_history(&realization_result.history);
|
2024-11-26 00:32:50 +00:00
|
|
|
}
|