Ver Fonte

add Mat3.isIdentity

Alexander Rose há 5 anos atrás
pai
commit
4287d158b6
1 ficheiros alterados com 6 adições e 1 exclusões
  1. 6 1
      src/mol-math/linear-algebra/3d/mat3.ts

+ 6 - 1
src/mol-math/linear-algebra/3d/mat3.ts

@@ -17,7 +17,7 @@
  * furnished to do so, subject to the following conditions:
  */
 
-import { Mat4, Vec3 } from '../3d'
+import { Mat4, Vec3, EPSILON } from '../3d'
 import { NumberArray } from '../../../mol-util/type-helpers';
 
 interface Mat3 extends Array<number> { [d: number]: number, '@type': 'mat3', length: 9 }
@@ -118,6 +118,11 @@ namespace Mat3 {
         return out;
     }
 
+    const _id = identity();
+    export function isIdentity(m: Mat3, eps?: number) {
+        return areEqual(m, _id, typeof eps === 'undefined' ? EPSILON : eps);
+    }
+
     export function hasNaN(m: Mat3) {
         for (let i = 0; i < 9; i++) if (isNaN(m[i])) return true
         return false