summaryrefslogtreecommitdiff
path: root/src/lsq_rectilinear.mac
blob: a06670de228663300e632c4d0fdeab0e95fc5017 (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
/*
 * rectilinear (pinhole) projection model with distortion correction
 */

/* angle over horizon in view direction */
a_h : atan (tan (m_nick) / cos(m_view - c_view))$

/* adjust angle according to nick value */
a_v : atan(cos(c_nick + a_h) * tan(m_view - c_view) / cos(a_h))$

x : tan(a_v)$
y : tan(c_nick - a_h)$ 
x_rot : y * sin(c_tilt) + x * cos(c_tilt)+x0$
y_rot : y * cos(c_tilt) - x * sin(c_tilt)$
d : x_rot ^ 2 + y_rot ^ 2$
dist_fact : d ^ 2 * k1 + d * k0$
x_dist : x_rot * (1 + dist_fact) * scale$
y_dist : y_rot * (1 + dist_fact) * scale$

/*
 * Some mangling for C code generation
 */

load("expr2c.mac")$

x_expand : trigexpand(x_dist)$
y_expand : trigexpand(y_dist)$

args: "double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick"$

expr2c("ProjectionRectilinear::mac_x", args, x_expand)$
expr2c("ProjectionRectilinear::mac_y", args, y_expand)$

expr2c("ProjectionRectilinear::mac_x_dc_view", args, diff(x_expand, c_view))$
expr2c("ProjectionRectilinear::mac_x_dc_nick", args, diff(x_expand, c_nick))$
expr2c("ProjectionRectilinear::mac_x_dc_tilt", args, diff(x_expand, c_tilt))$
expr2c("ProjectionRectilinear::mac_x_dscale", args, diff(x_expand, scale))$
expr2c("ProjectionRectilinear::mac_x_dk0", args, diff(x_expand, k0))$
expr2c("ProjectionRectilinear::mac_x_dk1", args, diff(x_expand, k1))$
expr2c("ProjectionRectilinear::mac_x_dx0", args, diff(x_expand, x0))$
expr2c("ProjectionRectilinear::mac_y_dc_view", args, diff(y_expand, c_view))$
expr2c("ProjectionRectilinear::mac_y_dc_nick", args, diff(y_expand, c_nick))$
expr2c("ProjectionRectilinear::mac_y_dc_tilt", args, diff(y_expand, c_tilt))$
expr2c("ProjectionRectilinear::mac_y_dscale", args, diff(y_expand, scale))$
expr2c("ProjectionRectilinear::mac_y_dk0", args, diff(y_expand, k0))$
expr2c("ProjectionRectilinear::mac_y_dk1", args, diff(y_expand, k1))$
expr2c("ProjectionRectilinear::mac_y_dx0", args, diff(y_expand, x0))$