2025-06-09 22:21:34 -07:00
|
|
|
mod common;
|
|
|
|
|
|
|
|
use common::{
|
|
|
|
print_config,
|
|
|
|
print_gram_matrix,
|
|
|
|
print_loss_history,
|
|
|
|
print_realization_diagnostics,
|
|
|
|
print_title
|
|
|
|
};
|
|
|
|
use dyna3::engine::{
|
|
|
|
point,
|
|
|
|
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
|
|
|
point(0.0, 0.0, 2.0),
|
|
|
|
sphere(0.0, 0.0, 0.0, 1.0)
|
|
|
|
]);
|
2025-04-21 23:40:42 +00:00
|
|
|
for j in 0..2 {
|
|
|
|
for k in j..2 {
|
|
|
|
problem.gram.push_sym(j, k, if (j, k) == (1, 1) { 1.0 } else { 0.0 });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
problem.frozen.push(3, 0, problem.guess[(3, 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-06-09 22:21:34 -07:00
|
|
|
print_title("Point on a sphere");
|
|
|
|
print_realization_diagnostics(&realization_result);
|
|
|
|
if let Ok(Realization{ config, .. }) = realization_result.result {
|
|
|
|
print_gram_matrix(&config);
|
|
|
|
print_config(&config);
|
2024-11-26 00:32:50 +00:00
|
|
|
}
|
2025-06-09 22:21:34 -07:00
|
|
|
print_loss_history(&realization_result.history);
|
2024-11-26 00:32:50 +00:00
|
|
|
}
|