summaryrefslogtreecommitdiff
path: root/crates/gipfel-core/src/projection/cylindrical.rs
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-26 20:05:20 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-26 20:05:20 +0100
commit375d87a9b0ec1cf2fffd705adb870c86144d2400 (patch)
tree1e8e05e7cd58686628d0f4622622456613a42e4d /crates/gipfel-core/src/projection/cylindrical.rs
parent45425dd047b791fe63f13a46a3251c529cfffc94 (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/cylindrical.rs')
-rw-r--r--crates/gipfel-core/src/projection/cylindrical.rs86
1 files changed, 86 insertions, 0 deletions
diff --git a/crates/gipfel-core/src/projection/cylindrical.rs b/crates/gipfel-core/src/projection/cylindrical.rs
new file mode 100644
index 0000000..9adf79c
--- /dev/null
+++ b/crates/gipfel-core/src/projection/cylindrical.rs
@@ -0,0 +1,86 @@
+//! Cylindrical projection.
+
+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/cylindrical_funcs.rs");
+}
+
+use super::{ProjArgs, Projection};
+
+pub struct ProjectionCylindrical;
+
+impl Projection for ProjectionCylindrical {
+ fn get_view_angle(&self) -> f64 {
+ 6.2831853 /* 360 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_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)
+ }
+}