How do I calculate x, y, z velocity given two rotation angles and a speed?
Another way of saying this question: How do I find the length, width and height of a cuboid given it's diagonal length and 2 rotational angles.
This is for a 3d game where the user can change up/down rotation (UP and DOWN arrow keys), left/right rotation (LEFT and RIGHT arrow keys) and the object can accelerated and reverse (Q and w). Each frame, the objects x, y, z gets updated according to it's current speed and up/down and left/right rotation.
If alpha is the left/right angle and beta is the up/down angle, then
v.x = speed * sin (alpha) * cos(beta) v.y = speed * sin (beta) v.z = speed * cos (alpha) * cos(beta)
Assuming, that no rotation will return the direction (0, 0, 1)
I'm assuming that this cuboid is measured using a static frame of reference, where the diagonal starts at the origin and extends to some other point. If not, this question has no definitive answer, as a diagonal length alone can not determine the width, height and length of some arbitrary cuboid, as there are an infinite number of cuboids that could have the same diagonal.
It sounds like what you're using is a spherical coordinate system: http://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates
From the article:
x = r sin θ cos φ y = r sin θ sin φ z = r cos θ
r is your diagonal length. You'll have to determine θ and φ based on your rotation angles; they may not be proper inclination and azimuth angles. See the article for details on how these angles are defined in spherical coordinates.