user1577802
user1577802

Reputation: 196

pitch yaw roll, angle independency

I am trying hard to figure out how to make pitch yaw and roll independent between them. As soon as I rotate something in the z axis (pitch) the second rotation (yaxis yaw) depends on the results of the first and the third rotation (x axis, roll) depends on the other two. So instead of having independent pitch,yaw,roll I get a mixture of the three of them, ugly.

I wish it was possible to store the object angles in an array [pitch,yaw,roll] and then decode those angles during the transformation so that yawing put the object in a given position and then it took the angle corresponding to the pitch, but not a compound of both...

I have seen references to an 'arbitrary axis rotation matrix'. Would it be useful to get the desired results??? 1) apply yaw (gl.glRotatef(beta, 0.0f, 1.0f, 0.0f);) 2) get the resulting axis of manually rotating the vector (1.0f,0.0f,0.0f) arround beta 3) apply pitch using the axis got in 2 {and for roll... if 1,2,3 are correct} 4) rotate the axis got in 2 arround its x for a roll 5) apply roll using the axis got in 4

Would it work? Any better solution? I would like keeping my object local orientations in the [pitch,yaw,roll] format.

I have been struggling with it for days, I would like to avoid using quaternions if possible. The 3D objects are stored relatively to 0,0,0 and looking along {1,0,0} and transformed to their destination and angles each frame, so the gimbal lock problem should probably be avoided easily.

In other words, my camera is working fine, World coordinates are being correctly made, but I do not know how or where object-local-transformations based on yaw,pith,roll should be applied.

The results should be read from the array [y,p,r] and combinations of them should not overlap.

Actually my transformations are:

gl.glLoadIdentity(); 
float[] scalation = transform.getScalation();
gl.glScalef(scalation[0], scalation[1], scalation[2]); 
float[] translation = transform.getTranslation();
gl.glTranslatef(translation[0], translation[1], translation[2]);
float[] rotation = transform.getRotation();
gl.glRotatef(rotation[0], 1.0f, 0.0f, 0.0f);
gl.glRotatef(rotation[1], 0.0f, 1.0f, 0.0f);
gl.glRotatef(rotation[2], 0.0f, 0.0f, 1.0f);

Upvotes: 1

Views: 8033

Answers (3)

Jepessen
Jepessen

Reputation: 12435

The orientation always depends on angles order. You can't make them indipendent. You rotate vectors multipling them by matrices, and matrix multiplication is not commutative. You can choose one order and be consistent with it. For these problems, a common choice is the ZYX orientation method (first roll, then pitch and at the end yaw). My personal reference when I work with angles is this document, that helps me a lot.

EDIT:

I've seen that actually the link is not correct. A working link for the document that I use is the following one:

Representing Attitude: Euler Angles, Unit Quaternions, and Rotation Vectors

Upvotes: 7

krokodil
krokodil

Reputation: 11

Accumulating (yaw, pitch, roll) rotations requires to keep a transformation matrix, which is the product of the separate transformations, in the order in which they occur. The resulting matrix is a rotation around some axis and some angle.

Upvotes: 1

jd.
jd.

Reputation: 1142

if you use yaw/pitch/roll, your final orientation will always depend on the amounts and order in which you apply them. you can choose other schemes if you want readability or simplicity. i like choosing a forward vector (F), and calculating a right and up vector based on a canonical 'world up' vector, then just filling in the matrix columns. You could add an extra 'axis spin' angle term, if you like. It's a bit like a quaternion, but more human-readable. I use this representation for controlling a basic WASD-style camera.

Upvotes: 4

Related Questions