Sign in to follow this  

OpenGL, drawing a rotated object

Recommended Posts

I have a point (x,y,z) in space. The point can be anywhere in space. I need to draw an object (basic stretched cube), which starts out facing (1,0,0), to face that the x,y,z point in space using a rotation matrix. The object's roll should remain in a consistent position (ie. I can't have the cube flip around so that its top faces down after the rotation). What is the best way to do this? I tried using cross and dot products to find an axis rotation between the objects, and the angle, then rotate using that. But that brings up the problem that the cube spins in strange directions even though it faces the right way. I also tried finding out the angle on the XY plane and the XZ plane and then rotating across known axes once by each, but I think I have problems with my algorithm because it doesn't end up facing the point it needs to some of the time. I'm using OpenGL implemented in C++. Any ideas would be apreciated.

Share this post

Link to post
Share on other sites

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