Yaw, pitch, roll (tait byran angles)

This is my first post on this forum not graphics related, that has all been sorted out now.

I am having a bit of a problem describing yaw, pitch and roll. I think the problem lies in how I control them, rather than how they map to xyz movement.

Here is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    YAW += virtualy * sin(ROLL * (PI/180));
    PITCH += virtualy * cos(ROLL * (PI/180)); ///problem line...
    ROLL += virtualx;

    ///virtualx and virtualy are altered by key presses,
    ///left key -> virtualx-- | right key -> virtualx++ 
    ///down key -> virtualy-- | up key -> virtualy++ 

    thrustx = sin(YAW * (PI/180)) * cos(PITCH * (PI/180));
    thrusty = sin(PITCH * (PI/180));
    thrustz = cos(YAW * (PI/180)) * cos(PITCH * (PI/180));

    force_x = thrustx;// + form_dragx;// /*+ gravity*/ + liftx; //would be += 
    // in reality, but for testing just =
    force_y = thrusty;// + form_dragy;// /*+ gravity*/ + lifty;
    force_z = thrustz;// + form_dragz;// /*+ gravity*/ + liftz;

    x += 0.01 * force_x;
    y += 0.01 * force_y;
    z += 0.01 * force_z;


As you can see in line 2, PITCH can be described using my method, but only when PITCH = 0, so it looks as though it must refer to itself??? I thought I had this sorted, but I worked on this a while ago.

I really need help, I looked at tait-byran matrices but have no idea what they mean. I need this complete within about 10 months.

*Edit: is there any way I can use glrotate to my advantage, I have it working on the graphics, so would there be some way to adapt it to this need as well?

Thankyou
Last edited on
Can anybody provide an answer, I really need this. Should this be in the beginner section?
What? How does this help me? Your post has been reported, it appears you are a regular troll, I do not understand by the looks of your previous contributions why you have not been banned.
Can anyone provide any real help, please?
I'm not a mathematician by any stretch but are you trying to work on a flight sim of some kind here? Is the problem relative rotations or something like that? If you are trying to do that with the above code I don't think you'll have much luck as matrix and better still quaternions are better suited. From a matrix you can get the forward, up and side vectors that it looks like you are using. Need a bit more info...
I am a bit confused as to what you are actually trying to calculate (though I am by no means an expert on this kind of physics simulation, so I could just not understand the process correctly).

My understanding is the pitch/yaw/roll are the angle of rotation all each axis of the object relative to the coordinate system. I'm not sure how you could "calculate" those from any kind of linear position (that is, an (x, y, z) coordinate) as the orientation and linear position are different and together they represent an object's position in space.
This appears to be a math problem rather than a coding problem. Work out the math details by hand. Calculate a few samples and then see if the code matches your hand calculations.
My understanding is the pitch/yaw/roll are the angle of rotation all each axis of the object relative to the coordinate system. I'm not sure how you could "calculate" those from any kind of linear position (that is, an (x, y, z) coordinate) as the orientation and linear position are different and together they represent an object's position in space.

This, plus more.

A 3D rotation is (mathematically) easiest to handle with quaternions. A transformation can be stored as a {quaternion,3D-(math)vector} pair. A transformation both rotates and translates (i.e. moves) an object.

An non-point object has both location and orientation (i.e. what is "up" and "forward" for the object). There are more than one "coordinate system" (aka frame of reference): one for the "world", one for the displayed area, one for the object, etc.

Let say that the object is a plane. Let the "action" to be "pull up X degrees and move forward Y parsecs". From the current orientation of the plane you can compute the axis of rotation (cross-product of up and forward). The axis and the angle can be used to create a quaternion. Multiplying the planes's forward and up (unit vectors) with it yield rotated forward and up. Amount of movement and forward yield the translation vector that adds to position to yield new, post-action position.

The correct order of operations is crucial.

Multiple transformations can be merged into single transformation.


Where the C++ kicks in, is that each of the mathematical concepts can be expressed as user-defined types and their overloaded operators can hide/factorize/encapsulate each "scary" math operation.

Better yet, you are not the first. Others have written and packaged such types already into "game engines" / "libraries".

The problem is thus to grasp the math and seek a library that best supports the operations that your application requires.
So, this is not just very complex, but extremely complex.

Your explanation makes sense, but I would have no idea as to how to go about implementing it.

I had not considered a library. This seems like cheating, but it looks like I will have to use one. Can you recommend one? I am not overly keen or practised in OO, so one which doesn't rely only classes and objects etc would be preferable, but if that's not an option, one that relies on heavier use of OO would be ok.

This is all so obscure, I am struggling to find help and am under a lot of pressure and have no qualifications. Thank you for your guidance.
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/general/196868/
Have you looked into opencv. They at least have types that represent 3d points and Mats, and facilities for matrix calculations.
Topic archived. No new replies allowed.