vector r is my rotation about the x, y, and z |
Ouch.. that is confusing!
You got us all mixed up because you use letters x,y,z to denote angles, instead of distances!
Convention: always denote angles with Greek letters, coordinates- with small Latin letters. Reason: everyone expects that. Doing anything different is bound to confuse readers (example: I completely misunderstood your notation).
****
What I would do if I were you: drop the angles altogether. Instead store rotation (orthonormal) matrix. Those are 9 coordinates, but after you orthonormalize, you get only 3 free parameters, so it's the same amount of information.
Now, if you DON'T want to drop the angles, and want to do things the hard way, there are a few things you should know.
Let rx_\alpha, ry_\beta, rz_\gamma be rotations relative at angles \alpha, \beta and \gamma relative to x, y and z axis.
1. applying first rx_\alpha and then ry_\beta IS NOT the same as applying ry_\beta first and rx_\alpha second. Same thing holds for all other pairs of rotations.
2. Hence you need to decide the order in which you shall carry the rotations. I'd presume you rotate first around x axis, then around y axis, then around z axis.
Now, the easiest way I can think of is to write the three rotations rx_\alpha, ry_\beta, rz_\gamma as matrices:
1 2 3 4
|
rx_\alpha=
( 1 0 0 )
( 0 cos \alpha -sin \alpha )
( 0 sin \alpha cos \alpha )
|
1 2 3 4
|
rz_\gamma=
( cos \gamma -sin \gamma 0 )
( sin \gamma cos \gamma 0 )
( 0 0 1 )
|
I omitted ry_\beta - exercise for you - write that yourself.
Now, to get the matrix of rotation: simply carry out the multiplication of matrices
matrix_rotation:= rx_\alpha * ry_\beta * rz_\gamma
(do you know how to multiply matrices?)
Finally, to get the "up" vector from the matrix_rotation:
simply multiply matrix_rotation by the vector-column
In other words, your "up" vector is the last, third column, of matrix_rotation.