Revision: 26197
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 20, 2010 11:17 by mattkenefick
Initial Code
var tempMatrix:Matrix3D = Matrix3D.inverse( new Matrix3D([0,0,0]) ); var vectorA:Number3D = new Number3D( 0,0,1 ); Matrix3D.multiplyVector( *OBJECT*.getPlane().transform, vectorA ); vectorA.normalize(); var vectorB:Number3D = new Number3D( 0,0,1 ); tempMatrix = Matrix3D.clone( *CLICKED-OBJECT*.transform ); Matrix3D.multiplyVector( tempMatrix, vectorB ); vectorB.normalize(); var angle:Number = Math.acos( Number3D.dot(vectorB, vectorA) / (vectorA.modulo*vectorB.modulo) )*180/Math.PI; trace( angle );
Initial URL
Initial Description
If you have multiple objects orbiting a 3D object and you want to determine the angle of a specific object, this will help you determine what rotationX you need to set your camera to if you want to be directly behind it. Note: It works completely in 3d space. So if your Y, Z, X are not inversed or directly related to your comparison object, the angle will be a little off.
Initial Title
Get angle from object in 3D space
Initial Tags
Initial Language
ActionScript 3