From 88296dd9b2c19f9dfd370b20087ec4e363852803 Mon Sep 17 00:00:00 2001 From: Oscar Lorentzon Date: Wed, 13 Jan 2016 11:05:44 +0100 Subject: [PATCH] Correct parameter type for Vector4.setAxisAngleFromRotationMatrix. The parameter to Vector4.setAxisAngleFromRotationMatrix is a Matrix4 from which the upper 3x3 matrix is used, not a Matrix3. See https://github.com/mrdoob/three.js/blob/master/src/math/Vector4.js#L271 for a reference. --- threejs/tests/math/test_unit_math.ts | 12 ++++++++++++ threejs/three.d.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/threejs/tests/math/test_unit_math.ts b/threejs/tests/math/test_unit_math.ts index 312a16b24f..0c92e970ae 100644 --- a/threejs/tests/math/test_unit_math.ts +++ b/threejs/tests/math/test_unit_math.ts @@ -3524,4 +3524,16 @@ ok( a.equals( b ), "Passed!" ); ok( b.equals( a ), "Passed!" ); }); + + test( "setAxisAngleFromRotationMatrix", function() { + var TOL = 1e-9; + + var r = new THREE.Matrix4().makeRotationZ(Math.PI / 2); + var v = new THREE.Vector4().setAxisAngleFromRotationMatrix(r); + + ok( v.x == 0, "Passed!" ); + ok( v.y == 0, "Passed!" ); + ok( v.z == 1, "Passed!" ); + ok( Math.abs(v.w - Math.PI / 2) < TOL, "Passed!" ); + }); }; diff --git a/threejs/three.d.ts b/threejs/three.d.ts index 0717427b33..37804860e8 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -4166,7 +4166,7 @@ declare module THREE { * http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm * @param m assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) */ - setAxisAngleFromRotationMatrix(m: Matrix3): Vector4; + setAxisAngleFromRotationMatrix(m: Matrix4): Vector4; min(v: Vector4): Vector4; max(v: Vector4): Vector4;