31 const double x1 = source[0].
x;
32 const double y1 = source[0].
y;
33 const double x2 = source[1].
x;
34 const double y2 = source[1].
y;
35 const double x3 = source[2].
x;
36 const double y3 = source[2].
y;
37 const double x4 = source[3].
x;
38 const double y4 = source[3].
y;
40 const double x_1 = target[0].
x;
41 const double y_1 = target[0].
y;
42 const double x_2 = target[1].
x;
43 const double y_2 = target[1].
y;
44 const double x_3 = target[2].
x;
45 const double y_3 = target[2].
y;
46 const double x_4 = target[3].
x;
47 const double y_4 = target[3].
y;
49 double P[9*9] = { -x1, -y1, -1.0, 0.0, 0.0, 0.0, x1 * x_1, y1 * x_1, x_1,
50 0.0, 0.0, 0.0, -x1, -y1, -1.0, x1 * y_1, y1 * y_1, y_1,
51 -x2, -y2, -1.0, 0.0, 0.0, 0.0, x2 * x_2, y2 * x_2, x_2,
52 0.0, 0.0, 0.0, -x2, -y2, -1.0, x2 * y_2, y2 * y_2, y_2,
53 -x3, -y3, -1.0, 0.0, 0.0, 0.0, x3 * x_3, y3 * x_3, x_3,
54 0.0, 0.0, 0.0, -x3, -y3, -1.0, x3 * y_3, y3 * y_3, y_3,
55 -x4, -y4, -1.0, 0.0, 0.0, 0.0, x4 * x_4, y4 * x_4, x_4,
56 0.0, 0.0, 0.0, -x4, -y4, -1.0, x4 * y_4, y4 * y_4, y_4,
57 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0};
60 for(
int i = 0;
i < 8;
i++) h_tmp[
i] = 0.0;
64 if(err_code)
for(
int i = 0;
i < 9;
i++) h[
i] = h_tmp[
i];
83 const float x =
p.
x * h[0 * 3 + 0] +
p.y * h[0 * 3 + 1] + h[0 * 3 + 2];
84 const float y =
p.x * h[1 * 3 + 0] +
p.y * h[1 * 3 + 1] + h[1 * 3 + 2];
85 const float s =
p.x * h[2 * 3 + 0] +
p.y * h[2 * 3 + 1] + h[2 * 3 + 2];
89 const float J00 = h[0 * 3 + 0] * s - h[2 * 3 + 0] *
x;
90 const float J01 = h[0 * 3 + 1] * s - h[2 * 3 + 1] *
x;
91 const float J10 = h[1 * 3 + 0] * s - h[2 * 3 + 0] * y;
92 const float J11 = h[1 * 3 + 1] * s - h[2 * 3 + 1] * y;
93 const float s2 = s * s;
94 return fabsf(J00 * J11 - J01 * J10) / (s2 * s2);