GetRotationX

Started by mkranga, June 29, 2013, 03:36:37 PM

Previous topic - Next topic

mkranga

Hi,

im rotation object(3d) using rotateX(n)
how do i get current rotation?(specific axis)

if jpct can have function like below would be grate
float  obj3d.GetRotationX()

thanks

EgonOlsen

You should try to avoid working with angles in that way if possible. You can derive angles from a matrix, but because each matrix can be created from an unlimited number of rotations, the angles don't reflect the actual angles that where used to create it but only one possible solution. If you need the angles, try to keep track of them yourself. You might as well use something like  this: http://www.jpct.net/forum2/index.php/topic,576.0.html

mkranga

My object interact with mouse. so its little  difficult to track rotation by my self.

This works.  Thank you .
public SimpleVector deriveAngles(Matrix mat) {
    SimpleVector s=new SimpleVector();
    float[] m=mat.getDump();
    s.x=(float) Math.atan(m[9]/m[10]);
    s.y=(float) Math.asin(-m[2]);
    s.z=(float) Math.atan(m[4]/m[0]);
    return s;
}