Public Group

# Space Controls

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

## Recommended Posts

Hiya,

I've edited this question, as it was poorly thought out.

Given a normalised direction vector, does anyone know how to find rotations around the x- and y-axis (pitch and yaw) which are equivalent?

From what I've read, I believe this is converting a vector into Euler angles, but I'm not entirely sure.

My reason for asking is that I have a space-ship object which can yaw and pitch, and I keep track of its orientation as a single direction vector. The pitch can never reach +/- 90 degrees, so the ship cannot become inverted - neither can it roll. I need to find the correct x/y rotation angles to pass to glRotatef().

Many thanks

##### Share on other sites
Yes, this is just converting a vector to Euler angles. There should be a billion or so references on how to do that floating around the web :-)

##### Share on other sites

Hiya,

I've edited this question, as it was poorly thought out.

Given a normalised direction vector, does anyone know how to find rotations around the x- and y-axis (pitch and yaw) which are equivalent?

From what I've read, I believe this is converting a vector into Euler angles, but I'm not entirely sure.

My reason for asking is that I have a space-ship object which can yaw and pitch, and I keep track of its orientation as a single direction vector. The pitch can never reach +/- 90 degrees, so the ship cannot become inverted - neither can it roll. I need to find the correct x/y rotation angles to pass to glRotatef().

Many thanks

Project the vector onto the YZ plane and take the dot product with the Z-axis to get the cosine of the pitch angle.
Project the vector onto the XZ plane and take the dot product with the Z-axis to get the cosine of the yaw angle.

This assumes positive Z is your intial direction vector.
XYZ axis here are your orientation base axis.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 21
• 21
• 11
• 9