diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-26 20:05:20 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-26 20:05:20 +0100 |
| commit | 375d87a9b0ec1cf2fffd705adb870c86144d2400 (patch) | |
| tree | 1e8e05e7cd58686628d0f4622622456613a42e4d /crates/gipfel-core/src/projection/rectilinear.rs | |
| parent | 45425dd047b791fe63f13a46a3251c529cfffc94 (diff) | |
Replace the C++ implementation with the Rust port
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.
Diffstat (limited to 'crates/gipfel-core/src/projection/rectilinear.rs')
| -rw-r--r-- | crates/gipfel-core/src/projection/rectilinear.rs | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/crates/gipfel-core/src/projection/rectilinear.rs b/crates/gipfel-core/src/projection/rectilinear.rs new file mode 100644 index 0000000..a7037d6 --- /dev/null +++ b/crates/gipfel-core/src/projection/rectilinear.rs @@ -0,0 +1,104 @@ +//! Rectilinear (gnomonic) projection with lens distortion. + +mod funcs { + #![allow(non_snake_case, unused_parens, unused_variables, dead_code, clippy::all)] + + // math shims: the maxima-generated code uses C-style calls + #[inline(always)] + fn sin(x: f64) -> f64 { + x.sin() + } + #[inline(always)] + fn cos(x: f64) -> f64 { + x.cos() + } + #[inline(always)] + fn tan(x: f64) -> f64 { + x.tan() + } + #[inline(always)] + fn sqrt(x: f64) -> f64 { + x.sqrt() + } + #[inline(always)] + fn pow(x: f64, y: f64) -> f64 { + x.powf(y) + } + #[inline(always)] + fn exp(x: f64) -> f64 { + x.exp() + } + #[inline(always)] + fn fabs(x: f64) -> f64 { + x.abs() + } + #[inline(always)] + fn atan2(y: f64, x: f64) -> f64 { + y.atan2(x) + } + #[inline(always)] + fn sec(x: f64) -> f64 { + 1.0 / x.cos() + } + + include!("generated/rectilinear_funcs.rs"); +} + +use super::{ProjArgs, Projection}; + +pub struct ProjectionRectilinear; + +impl Projection for ProjectionRectilinear { + fn get_view_angle(&self) -> f64 { + 1.0471976 /* 60 deg */ + } + + fn mac_x(&self, a: ProjArgs) -> f64 { + funcs::mac_x(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_y(&self, a: ProjArgs) -> f64 { + funcs::mac_y(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_x_dc_view(&self, a: ProjArgs) -> f64 { + funcs::mac_x_dc_view(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_x_dc_pitch(&self, a: ProjArgs) -> f64 { + funcs::mac_x_dc_pitch(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_x_dc_roll(&self, a: ProjArgs) -> f64 { + funcs::mac_x_dc_roll(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_x_dscale(&self, a: ProjArgs) -> f64 { + funcs::mac_x_dscale(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_x_dk0(&self, a: ProjArgs) -> f64 { + funcs::mac_x_dk0(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_x_dk1(&self, a: ProjArgs) -> f64 { + funcs::mac_x_dk1(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_x_dx0(&self, a: ProjArgs) -> f64 { + funcs::mac_x_dx0(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_y_dc_view(&self, a: ProjArgs) -> f64 { + funcs::mac_y_dc_view(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_y_dc_pitch(&self, a: ProjArgs) -> f64 { + funcs::mac_y_dc_pitch(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_y_dc_roll(&self, a: ProjArgs) -> f64 { + funcs::mac_y_dc_roll(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_y_dscale(&self, a: ProjArgs) -> f64 { + funcs::mac_y_dscale(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_y_dk0(&self, a: ProjArgs) -> f64 { + funcs::mac_y_dk0(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_y_dk1(&self, a: ProjArgs) -> f64 { + funcs::mac_y_dk1(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } + fn mac_y_dx0(&self, a: ProjArgs) -> f64 { + funcs::mac_y_dx0(a.c_view, a.c_pitch, a.c_roll, a.scale, a.k0, a.k1, a.x0, a.m_view, a.m_elev) + } +} |
