|
@@ -743,6 +743,8 @@ namespace Mat4 {
|
|
|
* Check if the matrix has the form
|
|
|
* [ Rotation Translation ]
|
|
|
* [ 0 1 ]
|
|
|
+ *
|
|
|
+ * Allows for improper rotations
|
|
|
*/
|
|
|
export function isRotationAndTranslation(a: Mat4, eps?: number) {
|
|
|
return _isRotationAndTranslation(a, typeof eps !== 'undefined' ? eps : EPSILON)
|
|
@@ -752,12 +754,14 @@ namespace Mat4 {
|
|
|
const a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
|
|
|
a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
|
|
|
a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
|
|
|
- /* a30 = a[12], a31 = a[13], a32 = a[14],*/ a33 = a[15];
|
|
|
+ a33 = a[15];
|
|
|
|
|
|
if (!equalEps(a33, 1, eps) || !equalEps(a03, 0, eps) || !equalEps(a13, 0, eps) || !equalEps(a23, 0, eps)) {
|
|
|
return false;
|
|
|
}
|
|
|
- const det3x3 = a00 * (a11 * a22 - a12 * a21) - a01 * (a10 * a22 - a12 * a20) + a02 * (a10 * a21 - a11 * a20);
|
|
|
+
|
|
|
+ // use `abs` to allow for improper rotations
|
|
|
+ const det3x3 = Math.abs(a00 * (a11 * a22 - a12 * a21) - a01 * (a10 * a22 - a12 * a20) + a02 * (a10 * a21 - a11 * a20));
|
|
|
if (!equalEps(det3x3, 1, eps)) {
|
|
|
return false;
|
|
|
}
|