# Rotation Question

This topic is 4216 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

ok so i have a 3D object... and it's rotated Yaw, Pitch, Roll arbitrary amount yaw, pitch, roll what i want it to do is that if, say it's already rolls +15 degrees and i want to yaw or pitch the thing after that... like an airplane... im pretty sure that this has been discussed somewhere on gamedev, but i cant find one that i understand... im VERY lacking in trig/Matrix/vector math thank you

##### Share on other sites
I gather you want all rotations to be about the object's local axes rather than the world axes, correct?

If so, you'll have to ditch Euler angles (at least as you're using them currently) and instead maintain your object's orientation from frame to frame (most likely in matrix or quaternion form). You then update the orientation incrementally by applying relative rotations about the object's local axes.

This does require some knowledge of 3D math, and/or a math library that can perform these functions for you. If you get stuck or need additional help, I can point you to some source code that might be of use to you.

##### Share on other sites
right, i understand what you're saying, but i dont know how to do it...

so i have the Starting matrix (Matrix.Zero?) and I add a Matrix.RotationYawPitchRoll to it? or do i completely forget about yawpitchroll...

I get the concept, i just dont actually know how to do it...

##### Share on other sites
Quote:
 Original post by perkbrianright, i understand what you're saying, but i dont know how to do it...so i have the Starting matrix (Matrix.Zero?) and I add a Matrix.RotationYawPitchRoll to it? or do i completely forget about yawpitchroll...I get the concept, i just dont actually know how to do it...
Your starting matrix can be any orientation (although identity is often a sensible choice). From there, you update the orientation incrementally each frame or 'tick' using small (generally speaking) rotations about the object's local axes.

Note that concatenating rotations in matrix or quaternion form does not involve addition, but rather multiplication.

You can use your RotationYawPitchRoll() function, but the rotation needs to be applied locally, not globally. Based on your mention of this function I'm going to venture a guess that you're using row-vector notation. With this notational convention, the 'delta' rotation should go on the left, e.g.:
Matrix44 delta;delta.RotationYawPitchRoll(yaw * dt, pitch * dt, roll * dt);my_orientation = delta * my_orientation;my_orientation.orthogonalize();
When using column-vector notation, the terms should be reversed. Also, note that when using incremental rotations the orientation matrix should be orthogonalized periodically to prevent drift (with quaternions this equates to normalization).

##### Share on other sites
...how do i orthogonolize? im using Microsoft.DirectX.Matrix and the only function it has with anything to do with orthogonalization is OrthoRH and OrthoLH...

which both do "Builds a Left/Right-handed Orthogonal projection matrix" they take

Width,Height,zNearPlane and zFarPlane... all floats...

is that what i need?

##### Share on other sites
Quote:
 Original post by perkbrianis that what i need?
Nope, those functions are for building an orthographic projection, which is unrelated.

Orthogonalizing a rotation matrix is more or less equivalent to orthonormalizing a set of basis vectors. An easy way to do the latter in 3D is:
forward.normalize();side = cross(up,forward);side.normalize();up = cross(forward,side);
To orthogonalize your rotation matrix, simply extract the basis vectors, perform the above operations, and then reset the basis vectors of the matrix.

##### Share on other sites
thank you very much, it works perfectly...

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 12
• 18
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632662
• Total Posts
3007702
• ### Who's Online (See full list)

There are no registered users currently online

×