### Author Topic: Is a helper method to rotate models by yaw, pitch, roll angles?  (Read 784 times)

#### arekz

• byte
• Posts: 8
##### Is a helper method to rotate models by yaw, pitch, roll angles?
« 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).

Code: [Select]
`            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.

#### EgonOlsen

• Posts: 12065
##### Re: Is a helper method to rotate models by yaw, pitch, roll angles?
« Reply #1 on: July 14, 2016, 10:30:57 am »
I'm not sure, if I understand the problem correctly!? If I did, just convert from degrees to radians. It's dead simple:

Code: [Select]
`float rad=euler*(float)Math.PI/180f`

#### arekz

• byte
• Posts: 8
##### Re: Is a helper method to rotate models by yaw, pitch, roll angles?
« Reply #2 on: July 14, 2016, 10:45:37 am »

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)
Code: [Select]
`    obj3d..clearRotation();        obj3d.rotateX(measurements.pitch);      obj3d.rotateY(measurements.yaw);        obj3d.rotateZ(measurements.roll);`then this one:
Code: [Select]
`    obj3d..clearRotation();      obj3d.rotateZ(measurements.roll);          obj3d.rotateY(measurements.yaw);      obj3d.rotateX(measurements.pitch);  `right?

#### EgonOlsen

`obj.rotateAxis(obj.getXAxis(), radX);obj.rotateAxis(obj.getYAxis(), radY);...`