summaryrefslogtreecommitdiff
path: root/crates/gipfel-core/src/projection/cylindrical.rs
blob: 9adf79cc673df2f240261ef855bea6249cd02ee0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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)
    }
}