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
|
/*
* rectilinear (pinhole) projection model with distortion correction
*/
c_x : cos(m_nick) * cos(m_view-c_view)$
c_y : cos(m_nick) * sin(m_view-c_view)$
c_z : sin(m_nick)$
/*
c_x_rot1 : cos(c_view) * c_x - sin(c_view) * c_y$
c_y_rot1 : sin(c_view) * c_x + cos(c_view) * c_y$
c_z_rot1 : c_z$
c_x_rot2 : c_x_rot1$
c_y_rot2 : cos(c_nick) * c_y_rot1 - sin(c_nick) * c_z_rot1$
c_z_rot2 : sin(c_nick) * c_y_rot1 - cos(c_nick) * c_z_rot1$
c_x_rot2 : cos(c_nick) * c_x_rot1$ + sin(c_nick) * c_z_rot1$
c_y_rot2 : c_y_rot1$
c_z_rot2 : -sin(c_nick) * c_x_rot1 + cos(c_nick) * c_z_rot1$
*/
a_h : c_nick - (\pi/2 - acos(c_z))$
a_v : atan(c_y / c_x)$
/* angle over horizon in view direction */
/* a_h : atan (tan (m_nick) * sqrt(tan(m_view - c_view) ^2 + 1))$ */
/* adjust angle according to nick value */
/* a_v : atan(cos(c_nick - a_h ) * tan((m_view - c_view) / cos(a_h)))$ */
/* a_v : m_view - c_view$ */
x : tan(a_v)$
y : tan(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))$
|