ref: 01698b29669f3339a7289e0d726f8a6e30d07297
parent: 8e1d6128c8e93dfb9216e328b1b889deb72b4796
author: rodri <rgl@antares-labs.eu>
date: Tue May 27 12:22:16 EDT 2025
warp: add fixes and references
--- a/warp.c
+++ b/warp.c
@@ -51,9 +51,9 @@
0, 0, 1, 0,
0, 0, 0, 1,
};
- mulm3(Ry, Rz);
- mulm3(Rx, Ry);
- memmove(m, Rx, sizeof(Matrix3));
+ mulm3(Ry, Rx);
+ mulm3(Rz, Ry);
+ memmove(m, Rz, sizeof(Matrix3));
}
static void
@@ -107,6 +107,11 @@
memmove(m, Sxz, sizeof(Matrix3));
}
+/*
+ * references:
+ * - http://stackoverflow.com/questions/17087446/how-to-calculate-perspective-transform-for-opencv-from-rotation-angles
+ * - http://jepsonsblog.blogspot.tw/2012/11/rotation-in-3d-using-opencvs.html
+ */
static void
mkxform(Matrix m, Mstk *stk, Memimage *s)
{
@@ -116,7 +121,7 @@
w = Dx(s->r);
h = Dy(s->r);
- d = sqrt(w*w + h*h);
+ d = hypot(w, h);
focal = γ == 0? d: d / 2*sin(γ);
identity3(U);
@@ -133,7 +138,7 @@
}, A1 = {
1, 0, -w/2, 0,
0, 1, -h/2, 0,
- 0, 0, 1, 0,
+ 0, 0, 0, 0,
0, 0, 1, 0,
}, A2 = {
focal, 0, w/2, 0,
--
⑨