www.jpct.net
jPCT-AE - a 3d engine for Android => Support => Topic started by: arekz on July 14, 2016, 10:09:48 am
-
As we know the multiplication of rotation matrix aren't commutative so I need rotate the Object3D at once by three angles (Yaw, Pitch, Roll)
I get this angles form external source (not sensors).
obj3d..clearRotation();
obj3d.rotateY(measurements.yaw);
obj3d.rotateX(measurements.pitch);
obj3d.rotateZ(measurements.roll);
So is there any helper method to solve that?
for example in libgdx I used method Matrix..setFromEulerAnglesRad() and then I make multiplication that matrix with transform matrix. Unfortnightly the Object3D class not contain any method rotateByEurelAngles() or similar or I miss something.
-
I'm not sure, if I understand the problem correctly!? If I did, just convert from degrees to radians. It's dead simple:
float rad=euler*(float)Math.PI/180f
-
My angles are in radius already.
My problem is that if I rotate by X axis then by Y axis and then by Z axis I will have different model pose if I first rotate by Z axis then by Y axis and finally by X axis.
So below code give me diffrent result (model pose)
obj3d..clearRotation();
obj3d.rotateX(measurements.pitch);
obj3d.rotateY(measurements.yaw);
obj3d.rotateZ(measurements.roll);
then this one:
obj3d..clearRotation();
obj3d.rotateZ(measurements.roll);
obj3d.rotateY(measurements.yaw);
obj3d.rotateX(measurements.pitch);
right?
-
I see. You can use this method for that: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#rotateAxis(com.threed.jpct.SimpleVector, float) (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#rotateAxis(com.threed.jpct.SimpleVector, float))
Just do something like:
obj.rotateAxis(obj.getXAxis(), radX);
obj.rotateAxis(obj.getYAxis(), radY);
...