Commit: 0115568ca6537260b2f177bf59edd55d07904099 Author: Tiago Chaves Date: Thu Feb 20 12:48:42 2020 +1100 Branches: master https://developer.blender.org/rB0115568ca6537260b2f177bf59edd55d07904099
BLI_math: add 2x2 matrix utilities =================================================================== M source/blender/blenlib/BLI_math_matrix.h M source/blender/blenlib/intern/math_matrix.c =================================================================== diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 73731255882..7845e0998e0 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -48,6 +48,8 @@ void copy_m3_m3(float R[3][3], const float A[3][3]); void copy_m4_m4(float R[4][4], const float A[4][4]); void copy_m3_m4(float R[3][3], const float A[4][4]); void copy_m4_m3(float R[4][4], const float A[3][3]); +void copy_m3_m2(float R[3][3], const float A[2][2]); +void copy_m4_m2(float R[4][4], const float A[2][2]); void copy_m4_m4_db(double m1[4][4], const double m2[4][4]); @@ -245,6 +247,10 @@ void transpose_m4_m4(float R[4][4], const float A[4][4]); int compare_m4m4(const float mat1[4][4], const float mat2[4][4], float limit); +void normalize_m2_ex(float R[2][2], float r_scale[2]) ATTR_NONNULL(); +void normalize_m2(float R[2][2]) ATTR_NONNULL(); +void normalize_m2_m2_ex(float R[2][2], const float A[2][2], float r_scale[2]) ATTR_NONNULL(); +void normalize_m2_m2(float R[2][2], const float A[2][2]) ATTR_NONNULL(); void normalize_m3_ex(float R[3][3], float r_scale[3]) ATTR_NONNULL(); void normalize_m3(float R[3][3]) ATTR_NONNULL(); void normalize_m3_m3_ex(float R[3][3], const float A[3][3], float r_scale[3]) ATTR_NONNULL(); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index efc754acab1..d5f4a793ad0 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -143,6 +143,44 @@ void copy_m4_m3(float m1[4][4], const float m2[3][3]) /* no clear */ m1[3][3] = 1.0f; } +void copy_m3_m2(float m1[3][3], const float m2[2][2]) +{ + m1[0][0] = m2[0][0]; + m1[0][1] = m2[0][1]; + m1[0][2] = 0.0f; + + m1[1][0] = m2[1][0]; + m1[1][1] = m2[1][1]; + m1[1][2] = 0.0f; + + m1[2][0] = 0.0f; + m1[2][1] = 0.0f; + m1[2][2] = 1.0f; +} + +void copy_m4_m2(float m1[4][4], const float m2[2][2]) +{ + m1[0][0] = m2[0][0]; + m1[0][1] = m2[0][1]; + m1[0][2] = 0.0f; + m1[0][3] = 0.0f; + + m1[1][0] = m2[1][0]; + m1[1][1] = m2[1][1]; + m1[1][2] = 0.0f; + m1[1][3] = 0.0f; + + m1[2][0] = 0.0f; + m1[2][1] = 0.0f; + m1[2][2] = 1.0f; + m1[2][3] = 0.0f; + + m1[3][0] = 0.0f; + m1[3][1] = 0.0f; + m1[3][2] = 0.0f; + m1[3][3] = 1.0f; +} + void copy_m4d_m4(double m1[4][4], const float m2[4][4]) { m1[0][0] = m2[0][0]; @@ -1755,6 +1793,37 @@ bool is_uniform_scaled_m4(const float m[4][4]) return is_uniform_scaled_m3(t); } +void normalize_m2_ex(float mat[2][2], float r_scale[2]) +{ + int i; + for (i = 0; i < 2; i++) { + r_scale[i] = normalize_v2(mat[i]); + } +} + +void normalize_m2(float mat[2][2]) +{ + int i; + for (i = 0; i < 2; i++) { + normalize_v2(mat[i]); + } +} + +void normalize_m2_m2_ex(float rmat[2][2], const float mat[2][2], float r_scale[2]) +{ + int i; + for (i = 0; i < 2; i++) { + r_scale[i] = normalize_v2_v2(rmat[i], mat[i]); + } +} +void normalize_m2_m2(float rmat[2][2], const float mat[2][2]) +{ + int i; + for (i = 0; i < 2; i++) { + normalize_v2_v2(rmat[i], mat[i]); + } +} + void normalize_m3_ex(float mat[3][3], float r_scale[3]) { int i; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs