diff options
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_matrix.h | 3 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 5667fb79332..0a442687ffc 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -148,6 +148,9 @@ void loc_quat_size_to_mat4(float R[4][4], void blend_m3_m3m3(float R[3][3], float A[3][3], float B[3][3], float t); void blend_m4_m4m4(float R[4][4], float A[4][4], float B[4][4], float t); +int is_negative_m3(float mat[3][3]); +int is_negative_m4(float mat[4][4]); + /*********************************** Other ***********************************/ void print_m3(char *str, float M[3][3]); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 47b99bce8ab..4765a1f4728 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1037,6 +1037,21 @@ void blend_m4_m4m4(float out[][4], float dst[][4], float src[][4], float srcweig loc_quat_size_to_mat4(out, floc, fquat, fsize); } + +int is_negative_m3(float mat[][3]) +{ + float vec[3]; + cross_v3_v3v3(vec, mat[0], mat[1]); + return (dot_v3v3(vec, mat[2]) < 0.0f); +} + +int is_negative_m4(float mat[][4]) +{ + float vec[3]; + cross_v3_v3v3(vec, mat[0], mat[1]); + return (dot_v3v3(vec, mat[2]) < 0.0f); +} + /* make a 4x4 matrix out of 3 transform components */ /* matrices are made in the order: scale * rot * loc */ // TODO: need to have a version that allows for rotation order... @@ -1128,4 +1143,3 @@ void print_m4(char *str, float m[][4]) printf("%f %f %f %f\n",m[0][3],m[1][3],m[2][3],m[3][3]); printf("\n"); } - |