diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2020-11-21 16:06:02 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2021-10-20 12:58:19 +0300 |
commit | dfa1c7e554fcc3ddd40780fb8555cdd6e90eaba3 (patch) | |
tree | eb3927f1f151e21e131f064304321b4c57f249fa /source/blender/blenlib/intern/math_matrix.c | |
parent | 6cd191a660394042a9df701d7ee9164881fc316b (diff) |
Split and extend unit tests for vec_roll_to_mat3_normalized.
Separate the huge test into huge logical parts and add more cases
to check. Also add a utility to check that the matrix is orthogonal,
with arbitrary epsilon values and calculations in double.
A couple of tests deliberately fail, to be fixed in following commits.
Ref D9551
Diffstat (limited to 'source/blender/blenlib/intern/math_matrix.c')
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 554506e90e7..b6d80d76be1 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -180,6 +180,21 @@ void copy_m4_m2(float m1[4][4], const float m2[2][2]) m1[3][3] = 1.0f; } +void copy_m3d_m3(double m1[3][3], const float m2[3][3]) +{ + m1[0][0] = m2[0][0]; + m1[0][1] = m2[0][1]; + m1[0][2] = m2[0][2]; + + m1[1][0] = m2[1][0]; + m1[1][1] = m2[1][1]; + m1[1][2] = m2[1][2]; + + m1[2][0] = m2[2][0]; + m1[2][1] = m2[2][1]; + m1[2][2] = m2[2][2]; +} + void copy_m4d_m4(double m1[4][4], const float m2[4][4]) { m1[0][0] = m2[0][0]; @@ -1113,6 +1128,13 @@ float determinant_m4_mat3_array(const float m[4][4]) m[2][0] * (m[0][1] * m[1][2] - m[0][2] * m[1][1])); } +double determinant_m3_array_db(const double m[3][3]) +{ + return (m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) - + m[1][0] * (m[0][1] * m[2][2] - m[0][2] * m[2][1]) + + m[2][0] * (m[0][1] * m[1][2] - m[0][2] * m[1][1])); +} + bool invert_m3_ex(float m[3][3], const float epsilon) { float tmp[3][3]; |