Simplify matrix_3x3.c

This commit is contained in:
twinaphex 2017-04-20 10:25:54 +02:00
parent 3fb630c571
commit fa347475e8
1 changed files with 18 additions and 18 deletions

View File

@ -103,12 +103,9 @@ bool matrix_3x3_quad_to_square(
const float sx3, const float sy3, const float sx3, const float sy3,
math_matrix_3x3 *mat) math_matrix_3x3 *mat)
{ {
if (!matrix_3x3_square_to_quad(sx0, sy0, sx1, sy1, return matrix_3x3_square_to_quad(sx0, sy0, sx1, sy1,
sx2, sy2, sx3, sy3, sx2, sy2, sx3, sy3,
mat)) mat) ? matrix_3x3_invert(mat) : false;
return false;
return matrix_3x3_invert(mat);
} }
bool matrix_3x3_quad_to_quad( bool matrix_3x3_quad_to_quad(
@ -122,19 +119,22 @@ bool matrix_3x3_quad_to_quad(
const float sx3, const float sy3, const float sx3, const float sy3,
math_matrix_3x3 *mat) math_matrix_3x3 *mat)
{ {
math_matrix_3x3 quad_to_square, square_to_quad; math_matrix_3x3 square_to_quad;
if (!matrix_3x3_square_to_quad(dx0, dy0, dx1, dy1, if (matrix_3x3_square_to_quad(dx0, dy0, dx1, dy1,
dx2, dy2, dx3, dy3, dx2, dy2, dx3, dy3,
&square_to_quad)) &square_to_quad))
return false; {
math_matrix_3x3 quad_to_square;
if (matrix_3x3_quad_to_square(sx0, sy0, sx1, sy1,
sx2, sy2, sx3, sy3,
&quad_to_square))
{
matrix_3x3_multiply(*mat, quad_to_square, square_to_quad);
if (!matrix_3x3_quad_to_square(sx0, sy0, sx1, sy1, return true;
sx2, sy2, sx3, sy3, }
&quad_to_square)) }
return false;
matrix_3x3_multiply(*mat, quad_to_square, square_to_quad); return false;
return true;
} }