« Return to Thread: [Breaking Change] DO3D has new props localRotationX / Y /Z , pitch, yaw, roll are methods again

Re: [Breaking Change] DO3D has new props localRotationX/ Y /Z , pitch, yaw, roll are methods again

by Jon Bradley-2 :: Rate this Message:

Reply to Author | View in Thread

Ah, I'm a doofus. Didn't put in the matrix props correctly. This  
method is completely untested.

        public static function matrix2euler( m :Matrix3D,  
euler:Number3D=null, scale:Number3D=null ) : Number3D
        {
                euler = euler || new Number3D();

         var x:Number = 0;
         var y:Number = 0;
         var c:Number = 0;

         euler.y = -Math.asin( m.n13);
         c = Math.cos(ay);

         if ( Math.abs(c) > 0.005 )
         {
             x =  m.n33/c;
             y = -m.n23/c;

             euler.x = Math.atan2(y,x);

             x = m.n11/c;
             y = m.n12/c;

             euler.z = atan2(y,x);
         }
         else
         {
             euler.x = 0;
             x = m.n22;
             y = m.n21;
             euler.z = atan2(y,x);
         }

         //  Clamp values
         euler.x = (euler.x > 360) ? 360:((euler.x < 0) ? 0:euler.x);
         euler.y = (euler.y > 360) ? 360:((euler.y < 0) ? 0:euler.y);
         euler.z = (euler.z > 360) ? 360:((euler.z < 0) ? 0:euler.z);

                if(Papervision3D.useDEGREES)
                {
                        euler.x *= toDEGREES;
                        euler.y *= toDEGREES;
                        euler.z *= toDEGREES;
                }
               
                return euler;
     }




_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

 « Return to Thread: [Breaking Change] DO3D has new props localRotationX / Y /Z , pitch, yaw, roll are methods again