BLI_math: add helper function to extract XY 2D scale from a 4D matrix.

This commit is contained in:
Bastien Montagne 2017-04-26 11:55:50 +02:00
parent b2fde7b1ee
commit 2387ba93d2
2 changed files with 10 additions and 0 deletions

View File

@ -223,6 +223,7 @@ void scale_m4_fl(float R[4][4], float scale);
float mat3_to_scale(const float M[3][3]);
float mat4_to_scale(const float M[4][4]);
float mat4_to_xy_scale(const float M[4][4]);
void size_to_mat3(float R[3][3], const float size[3]);
void size_to_mat4(float R[4][4], const float size[3]);

View File

@ -1578,6 +1578,15 @@ float mat4_to_scale(const float mat[4][4])
return len_v3(unit_vec);
}
/** Return 2D scale (in XY plane) of given mat4. */
float mat4_to_xy_scale(const float M[4][4])
{
/* unit length vector in xy plane */
float unit_vec[3] = {(float)M_SQRT1_2, (float)M_SQRT1_2, 0.0f};
mul_mat3_m4_v3(M, unit_vec);
return len_v3(unit_vec);
}
void mat3_to_rot_size(float rot[3][3], float size[3], const float mat3[3][3])
{
/* keep rot as a 3x3 matrix, the caller can convert into a quat or euler */