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
|
/*
* cylindrical projection model
*/
x : m_view - c_view$
y : tan(c_nick - m_nick)$
x_rot : y * sin(c_tilt) + x * cos(c_tilt)$
y_rot : y * cos(c_tilt) - x * sin(c_tilt)$
x_scale : x_rot * scale$
y_scale : y_rot * scale$
/*
* Some mangling for C code generation
*/
x_expand : trigexpand(x_scale)$
y_expand : trigexpand(y_scale)$
args: "(double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double m_view, double m_nick)"$
printfunc(name, expression) := sprint("double ProjectionCylindrical::", name, args, "{ return ", string(subst(pow, "^", expression)), ";}", "
")$
printfunc("mac_x", x_expand)$
printfunc("mac_y", y_expand)$
printfunc("mac_x_dc_view", diff(x_expand, c_view))$
printfunc("mac_x_dc_nick", diff(x_expand, c_nick))$
printfunc("mac_x_dc_tilt", diff(x_expand, c_tilt))$
printfunc("mac_x_dscale", diff(x_expand, scale))$
printfunc("mac_x_dk0", diff(x_expand, k0))$
printfunc("mac_x_dk1", diff(x_expand, k1))$
printfunc("mac_y_dc_view", diff(y_expand, c_view))$
printfunc("mac_y_dc_nick", diff(y_expand, c_nick))$
printfunc("mac_y_dc_tilt", diff(y_expand, c_tilt))$
printfunc("mac_y_dscale", diff(y_expand, scale))$
printfunc("mac_y_dk0", diff(y_expand, k0))$
printfunc("mac_y_dk1", diff(y_expand, k1))$
|