Author Topic: getRotation problem?  (Read 223 times)

chao chen   «   on: October 11, 2011, 12:38:28 PM »
When I rotate a model by using "trace(this.getRotation(true).y)", and the Console show values between -90 and 90, not between -180 and 180 or between 0 and 360, Why??

Lezard Ebaristo   «   Reply #1 on: November 28, 2011, 09:32:48 AM »
I have exactly the same problem. Can anyone tell us what logic we have to adopt to make simple rotations such as "turn around itself (y axis)"

for (var i:int =0; i<360; i+=45)
{
   viewport3D.player.setRotation(0,i,0);
    trace (i, int(viewport3D.player.getRotation().y));
}

result: 

0 0
45 45
90 90
135 45
180 0
225 -44
270 -90
315 -45
360 0

Dani Estraña   «   Reply #2 on: November 28, 2011, 11:20:24 AM »
you can used :

var dir:Vector3D = Matrix3DUtils.getDir(pivot3D.global);
var ang:Number = Math.atan2( dir.x, dir.z ) * 180 / Math.PI;

Ariel Nehmad   «   Reply #3 on: November 30, 2011, 03:12:47 PM »
Hi, when you work with 3d transformations, the internal engine data are always vectors and matrices...so, when you set an angle, always needs to be converted into a matrix information.

The same when you request angles, we need to decompose the matrix to return angles, and usually these angles are euler angles.

is a good idea try to avoid angles as much as possible when you work in 3d space.

the method that Dani proposes is also good way to retrieve y-axis angles.

nurdogan erdem   «   Reply #4 on: May 25, 2012, 01:58:14 PM »
What is the purpose of a framework when i have to deal with Matrix calculations, instead of using a simple rotation? ;-)