From c88fa50a4c15f9317ae9faf56647c5480097b6be Mon Sep 17 00:00:00 2001 From: philogb Date: Sat, 18 Sep 2010 01:07:15 +0800 Subject: [PATCH] Add Matrix4.rotationAxisAngleMatrix --- src/core/Matrix4.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/core/Matrix4.js b/src/core/Matrix4.js index 0123653880..03f3003e34 100644 --- a/src/core/Matrix4.js +++ b/src/core/Matrix4.js @@ -294,6 +294,30 @@ THREE.Matrix4.rotationZMatrix = function ( theta ) { }; +THREE.Matrix4.rotationAxisAngleMatrix = function ( axis, angle ) { + + //Based on http://www.gamedev.net/reference/articles/article1199.asp + + var rot = new THREE.Matrix4(); + var c = Math.cos( angle ); + var s = Math.sin( angle ); + var t = 1 - c; + var x = axis.x, y = axis.y, z = axis.z; + + rot.n11 = t * x * x + c; + rot.n12 = t * x * y - s * z; + rot.n13 = t * x * z + s * y; + rot.n21 = t * x * y + s * z; + rot.n22 = t * y * y + c; + rot.n23 = t * y * z - s * x; + rot.n31 = t * x * z - s * y; + rot.n32 = t * y * z + s * x; + rot.n33 = t * z * z + c; + + return rot; + +}; + THREE.Matrix4.makeInvert = function ( m1 ) { //TODO: make this more efficient -- GitLab