[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43733] trunk/blender/source/blender/ blenlib/intern/math_matrix.c: Fix orthogonality check for mat3 and mat4

Sv. Lockal lockalsash at gmail.com
Thu Jan 26 18:11:45 CET 2012


Revision: 43733
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43733
Author:   lockal
Date:     2012-01-26 17:11:43 +0000 (Thu, 26 Jan 2012)
Log Message:
-----------
Fix orthogonality check for mat3 and mat4

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/math_matrix.c

Modified: trunk/blender/source/blender/blenlib/intern/math_matrix.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_matrix.c	2012-01-26 17:03:30 UTC (rev 43732)
+++ trunk/blender/source/blender/blenlib/intern/math_matrix.c	2012-01-26 17:11:43 UTC (rev 43733)
@@ -778,32 +778,38 @@
 	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])



More information about the Bf-blender-cvs mailing list