summaryrefslogtreecommitdiff
path: root/src/lsq_funcs.mac
blob: 3e1bc18913b66c82b34689bed55890d9420f04ba (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
/*
 * This is the basic pinhole projection model with distortion correction
 */
x_undist_unrot : tan(m_view - c_view) * scale$
y_undist_unrot : tan(m_nick - c_nick) * scale$
d : y_undist_unrot ^ 2 + x_undist_unrot ^ 2$
dist_fact : d ^2 * k1 + d * k0$
x_unrot : x_undist_unrot * dist_fact$
y_unrot : y_undist_unrot * dist_fact$
x : y_unrot * sin(c_tilt) + x_unrot * cos(c_tilt)$
y : y_unrot * cos(c_tilt) - x_unrot * sin(c_tilt)$
/*
 * Some mangling for C code generation
 */
x_expand : trigexpand(x)$
y_expand : trigexpand(y)$

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

sprint("double mac_x", args, "{ return",string(subst(pow, "^", x_expand)),";}","
")$
sprint("double mac_y", args, "{ return", string(subst(pow, "^",y_expand)),";}","
")$
sprint("double mac_x_dc_view", args, "{ return", string(subst(pow, "^",diff(x_expand, c_view))),";}","
")$
sprint("double mac_x_dc_nick", args, "{ return", string(subst(pow, "^",diff(x_expand, c_nick))),";}","
")$
sprint("double mac_x_dscale", args, "{ return",string(subst(pow, "^",diff(x_expand, scale))),";}","
")$
sprint("double mac_x_dk0", args, "{ return",string(subst(pow, "^",diff(x_expand, k0))),";}","
")$
sprint("double mac_x_dk1",args, "{ return", string(subst(pow, "^",diff(x_expand, k1))),";}","
")$
sprint("double mac_y_dc_view",args, "{ return", string(subst(pow, "^",diff(y_expand, c_view))),";}","
")$
sprint("double mac_y_dc_nick",args, "{ return", string(subst(pow, "^",diff(y_expand, c_nick))),";}","
")$
sprint("double mac_y_dscale", args, "{ return",string(subst(pow, "^",diff(y_expand, scale))),";}","
")$
sprint("double mac_y_dk0", args, "{ return",string(subst(pow, "^",diff(y_expand, k0))),";}","
")$
sprint("double mac_y_dk1",args, "{ return", string(subst(pow, "^",diff(y_expand, k1))),";}","
")$