Sign in to follow this  

Rotate to face function

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

If you intended to correct an error in the post then please contact us.

Recommended Posts


If you consider the rotation around each of those angles seperately, you'll see that a rotation around the y axis for example effectively moves the vertices in the xz plane. The line along which the sides of the cube should align can be used as the hypotenuse in basic trigonometry, while either distance in the x or z direction between the origin and the point you want to face can be used as opposite or adjacent side (which one depends on the coordinate system you're using) to compute the sin or cos of the angle.

The above is probably a better advice :)

Share this post


Link to post
Share on other sites
Quote:
Original post by kryotech
So I have a cube that I want to rotate to face a point in 3D space. I am limited to using x, y, z angles. Does anyone understand how this can be done?
Are you *sure* you're limited to using x, y, and z angles? (I ask because people often think they have to use Euler angles when in fact they do not.)

Share this post


Link to post
Share on other sites
Quote:
Original post by kryotech
Te software I'm using has commands that rotate the object around the x, y , and z axis. It doesn't have any other commands. I guess I need a generic rotate to face function as well, not one just for a cube.
What software is it?

Share this post


Link to post
Share on other sites
If you're really only able to use Euler angles for this, you can compute a pair of spherical angles from the vector from the box position to the target position using a Cartesian-to-spherical-coordinate conversion. (You only need two angles for this, so you can ignore the third.)

How to perform the conversion will depend on what conventions you're using (e.g. which axis is up), but will generally reduce to a couple of calls to (e.g.) atan2().

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this