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:
authorSv. Lockal <lockalsash@gmail.com>2012-01-26 21:11:43 +0400
committerSv. Lockal <lockalsash@gmail.com>2012-01-26 21:11:43 +0400
commit4514a4455be89bc0a789d78355321abe6cfd5112 (patch)
treeef24b574086661f66169065a1e172bcd5c3de719 /source/blender/blenlib/intern/math_matrix.c
parent5d49eff25a7e9425def74b175836ea6302113d90 (diff)
Fix orthogonality check for mat3 and mat4
Diffstat (limited to 'source/blender/blenlib/intern/math_matrix.c')
-rw-r--r--source/blender/blenlib/intern/math_matrix.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index cd54c944ba9..0c8c98988d1 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -778,32 +778,38 @@ void orthogonalize_m4(float mat[][4], int axis)
mul_v3_fl(mat[2], size[2]);
}
-int is_orthogonal_m3(float mat[][3])
+int is_orthogonal_m3(float m[][3])
{
- if (fabsf(dot_v3v3(mat[0], mat[1])) > 1.5f * FLT_EPSILON)
- return 0;
+ int i, j;
- if (fabsf(dot_v3v3(mat[1], mat[2])) > 1.5f * FLT_EPSILON)
- return 0;
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < i; j++) {
+ if (fabsf(dot_v3v3(m[i], m[j])) > 1.5f * FLT_EPSILON)
+ return 0;
+ }
- if (fabsf(dot_v3v3(mat[0], mat[2])) > 1.5f * FLT_EPSILON)
- return 0;
-
- return 1;
+ if (fabsf(dot_v3v3(m[i], m[i]) - 1) > 1.5f * FLT_EPSILON)
+ return 0;
+ }
+
+ return 1;
}
-int is_orthogonal_m4(float mat[][4])
+int is_orthogonal_m4(float m[][4])
{
- if (fabsf(dot_v3v3(mat[0], mat[1])) > 1.5f * FLT_EPSILON)
- return 0;
+ int i, j;
- if (fabsf(dot_v3v3(mat[1], mat[2])) > 1.5f * FLT_EPSILON)
- return 0;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < i; j++) {
+ if (fabsf(dot_vn_vn(m[i], m[j], 4)) > 1.5f * FLT_EPSILON)
+ return 0;
+ }
- if (fabsf(dot_v3v3(mat[0], mat[2])) > 1.5f * FLT_EPSILON)
- return 0;
-
- return 1;
+ if (fabsf(dot_vn_vn(m[i], m[i], 4) - 1) > 1.5f * FLT_EPSILON)
+ return 0;
+ }
+
+ return 1;
}
void normalize_m3(float mat[][3])