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.