app: port relevant transform tools to GimpGenericTransformTool

Derive GimpUnifiedTransformTool, GimpPerspectiveTool, and
GimpHandleTransformTool from GimpGenericTransformTool, eliminating
their common logic.

Remove gimp_transform_matrix_handles(), which is no longer used.
This commit is contained in:
Ell
2018-01-27 07:21:39 -05:00
parent 0334595cc1
commit 442be72630
8 changed files with 173 additions and 416 deletions

View File

@ -424,100 +424,6 @@ mod_gauss (gdouble matrix[],
return TRUE;
}
void
gimp_transform_matrix_handles (GimpMatrix3 *matrix,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gdouble x3,
gdouble y3,
gdouble x4,
gdouble y4,
gdouble t_x1,
gdouble t_y1,
gdouble t_x2,
gdouble t_y2,
gdouble t_x3,
gdouble t_y3,
gdouble t_x4,
gdouble t_y4)
{
GimpMatrix3 trafo;
gdouble opos_x[4];
gdouble opos_y[4];
gdouble pos_x[4];
gdouble pos_y[4];
gdouble coeff[8 * 9];
gdouble sol[8];
gint i;
g_return_if_fail (matrix != NULL);
opos_x[0] = x1;
opos_y[0] = y1;
opos_x[1] = x2;
opos_y[1] = y2;
opos_x[2] = x3;
opos_y[2] = y3;
opos_x[3] = x4;
opos_y[3] = y4;
pos_x[0] = t_x1;
pos_y[0] = t_y1;
pos_x[1] = t_x2;
pos_y[1] = t_y2;
pos_x[2] = t_x3;
pos_y[2] = t_y3;
pos_x[3] = t_x4;
pos_y[3] = t_y4;
for (i = 0; i < 4; i++)
{
coeff[i * 9 + 0] = opos_x[i];
coeff[i * 9 + 1] = opos_y[i];
coeff[i * 9 + 2] = 1;
coeff[i * 9 + 3] = 0;
coeff[i * 9 + 4] = 0;
coeff[i * 9 + 5] = 0;
coeff[i * 9 + 6] = -opos_x[i] * pos_x[i];
coeff[i * 9 + 7] = -opos_y[i] * pos_x[i];
coeff[i * 9 + 8] = pos_x[i];
coeff[(i + 4) * 9 + 0] = 0;
coeff[(i + 4) * 9 + 1] = 0;
coeff[(i + 4) * 9 + 2] = 0;
coeff[(i + 4) * 9 + 3] = opos_x[i];
coeff[(i + 4) * 9 + 4] = opos_y[i];
coeff[(i + 4) * 9 + 5] = 1;
coeff[(i + 4) * 9 + 6] = -opos_x[i] * pos_y[i];
coeff[(i + 4) * 9 + 7] = -opos_y[i] * pos_y[i];
coeff[(i + 4) * 9 + 8] = pos_y[i];
}
if (mod_gauss (coeff, sol, 8))
{
trafo.coeff[0][0] = sol[0];
trafo.coeff[0][1] = sol[1];
trafo.coeff[0][2] = sol[2];
trafo.coeff[1][0] = sol[3];
trafo.coeff[1][1] = sol[4];
trafo.coeff[1][2] = sol[5];
trafo.coeff[2][0] = sol[6];
trafo.coeff[2][1] = sol[7];
trafo.coeff[2][2] = 1;
}
else
{
/* this should not happen reset the matrix so the user sees that
* something went wrong
*/
gimp_matrix3_identity (&trafo);
}
gimp_matrix3_mult (&trafo, matrix);
}
gboolean
gimp_transform_matrix_generic (GimpMatrix3 *matrix,
const GimpVector2 *input_points,