summaryrefslogtreecommitdiff
path: root/crates/gipfel-core/src/lsq.rs
AgeCommit message (Collapse)Author
4 daysweb: refit view parameters when switching projectionJohannes Hofmann
View parameters are projection-specific: a cylindrical scale is linear in azimuth, a rectilinear one tangent-based. Switching projections kept the old parameters, so the display reinterpreted them; the first marker drag then refit in the NEW projection, converging to parameters that are valid there but garbage for the other one - and switching back showed that garbage until yet another refit happened to save it (exactly the reported panorama -> rect -> drag -> back -> crazy -> tiny-drag-fixes-it chain). * web: the projection dropdown now refits to the markers right after switching (no-op without markers), so parameters always match the active projection. * core: the wide-branch initial guess (markers >180 deg apart in the image, chosen by the sign of the pixel difference) is now gated to projections that can show more than a half-plane. Rectilinear (120 deg max view) always uses the shortest arc. * regression test: panorama fit -> rectilinear interlude -> refit recovers the panorama parameters exactly.
8 daysgrey out distortion controls in panorama mode; make core skip the fitJohannes Hofmann
Confirmed: the cylindrical projection formulas contain no k0/k1/x0 and its distortion derivative trait defaults are NaN, so a level-2 (distortion) fit cannot move anything there. Worse, comp_params zeroed the distortion parameters before the (doomed) calibration - so enabling 'Fit distortion' in panorama mode silently destroyed distortion a rectilinear fit had established. * core: comp_params probes whether the projection actually provides distortion derivatives (NaN trait default = no) and skips both the calibration reset and the level-2 lsq if not. Regression test asserts k0/k1/x0 survive a fit_distortion=true fit in cylindrical mode. * web: the fit-distortion checkbox AND the whole distortion-profiles group now sit in a <fieldset disabled> in cylindrical mode (opacity 0.45), so the dead controls are visibly inert. * dist: rebuilt.
8 dayscore: fix fit for wide panoramas (markers >180 deg apart in image)Johannes Hofmann
The initial guess in comp_params assumed the two markers are less than 180 deg apart: a_center started on the first marker and the scale came from the shortest-arc azimuth difference. In panoramas wider than 180 deg the markers can straddle the seam - e.g. at -170 deg and +170 deg of the view center they are 340 deg apart in the image but only 20 deg on the compass. The start was then off by up to 170 deg in azimuth and a factor of 17 in scale, and the fit never recovered. Fix: derive the image-space azimuth difference from the SIGN OF THE PIXEL DIFFERENCE (the user's marker placement tells us which branch was meant; the magnitude is unique modulo 2pi for panoramas below 360 deg), and start the view center between the markers in that branch. The golden fit tests now compare a_center modulo 2pi: the C harness settles wherever its >2pi input azimuths put it (380 deg), the Rust port normalizes (20 deg) - same physical solution. Tests: fits with markers 340 deg apart, 350 deg apart in reversed marker order, and 200 deg apart (just over the seam). All three fail without the fix (verified), pass with it.
8 dayscore: fix fit when north lies between the two markersJohannes Hofmann
With markers at e.g. 350 deg and 10 deg the raw azimuth difference is 340 deg instead of 20 deg. Two places choked on that: * ProjArgs::from_params fed the raw difference into the projection formulas. The cylindrical projection uses it LINEARLY (x = scale * (m_view - c_view)), so the 350 deg peak was projected 350 degrees of scale to the right of center instead of 10 degrees to the left - no parameter set can satisfy both markers and the panorama-mode fit fails. The rectilinear projection is periodic and unaffected. Fix: represent m_view as c_view + wrapped difference, so every consumer (fit residuals, Jacobian, project_point) sees the shortest arc. get_coordinates already normalized for exactly this reason; the fit path bypassed it. * comp_params derived the initial scale from |d_alph| = 340 deg, an initial scale off by a factor of 17 - this hit rectilinear mode too. Use the wrapped difference. Regression tests: two-marker fits across north for both projections (the cylindrical one fails without the fix), plus a direct check that a 350 deg peak projects to -10 deg * scale.
2026-10-26Replace the C++ implementation with the Rust portJohannes Hofmann
The Rust port (formerly gipfel-rs) is now the official successor to the FLTK/GSL C++ code base. This squashes the port into a single commit and removes the C++ sources (they remain in the git history below). Layout: crates/gipfel-core headless core: hills, panorama geometry, projections (maxima-generated derivatives), pure-Rust LM fit, gipfel: JPEG comment + EXIF I/O, profiles, stitching crates/gipfel-cli command-line tools (export, info, stitch, profiles) crates/gipfel-app Cosmic DE (libcosmic) GUI, binary name `gipfel` codegen/ maxima scripts + regen.sh for the projection code tests/ golden files + C++ reference harnesses (historical) The original README is kept for now; it will be updated to describe the Rust build. gipfel.dat, AUTHORS, ChangeLog and NEWS are unchanged.