diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-11-16 22:28:06 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-11-16 22:28:06 +0100 |
| commit | f2f2798e60acdb995924eed66864a106735bd3d3 (patch) | |
| tree | 63bab4c5e27eab617cb405f468e15aa90efcd5ec /crates/gipfel-core/src/lsq.rs | |
| parent | bb8696ba4e32bfc8cea2e41872f19b590fe782e7 (diff) | |
core: spread six center seeds across the full circle in the fit
Experiment requested while chasing the remaining placement-dependent
'fit failed' reports: the derived center seed (midpoint of the two
marker azimuths in the image-space branch) can itself be far off when
marker placements are rough, and the optimizer then never sees the
basin containing the true solution. The multi-start now tries six
center seeds 60 deg apart around the full circle, crossed with the
scale and pitch seeds (24 tiny LM runs - test suite time unchanged).
Whatever the marker placement, a seed now starts within 30 deg of any
conceivable true center.
Diffstat (limited to 'crates/gipfel-core/src/lsq.rs')
| -rw-r--r-- | crates/gipfel-core/src/lsq.rs | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/crates/gipfel-core/src/lsq.rs b/crates/gipfel-core/src/lsq.rs index 2073886..bb2030b 100644 --- a/crates/gipfel-core/src/lsq.rs +++ b/crates/gipfel-core/src/lsq.rs @@ -398,14 +398,23 @@ pub fn comp_params( // a marker - the "randomly sometimes fit failed" report. Try a // small set of seeds and keep the lowest-cost result. let mut best: Option<(f64, ViewParams)> = None; - for &s0 in &seed_scales { - for &p0 in &[0.0f64, pitch_seed(hills, known, s0)] { - let mut cand = new_parms; - cand.scale = s0; - cand.a_pitch = p0; - let cost = lsq(proj, hills, known, &mut cand, level); - if cost.is_finite() && best.as_ref().map_or(true, |(c, _)| cost < *c) { - best = Some((cost, cand)); + // The center seed derived from the two markers can itself be way + // off when marker placements are rough; spread six center seeds + // across the full circle (60 deg apart). 6 centers x 2 scales x + // 2 pitches = 24 tiny fits, still microseconds. + let c0 = new_parms.a_center; + for k in 0..6usize { + let c_seed = crate::projection::wrap_angle(c0 + k as f64 * (std::f64::consts::TAU / 6.0)); + for &s0 in &seed_scales { + for &p0 in &[0.0f64, pitch_seed(hills, known, s0)] { + let mut cand = new_parms; + cand.a_center = c_seed; + cand.scale = s0; + cand.a_pitch = p0; + let cost = lsq(proj, hills, known, &mut cand, level); + if cost.is_finite() && best.as_ref().map_or(true, |(c, _)| cost < *c) { + best = Some((cost, cand)); + } } } } |
