Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2017-04-26 12:55:50 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2017-04-26 13:00:15 +0300
commit2387ba93d268235d1f8faeec16e17c9d2c78fa21 (patch)
tree2fa87188fc54c8ef23050cf86c77d45e8c0dbed4 /source/blender/blenlib
parentb2fde7b1ee2151c027b5cbd03a6b75c7e9cd2739 (diff)
BLI_math: add helper function to extract XY 2D scale from a 4D matrix.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h1
-rw-r--r--source/blender/blenlib/intern/math_matrix.c9
2 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 029f6872b04..90aff1fcbbc 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -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]);
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 50b92f5a383..1883b62f532 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -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 */