Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Orient a Missile along it's velocity vector

This topic is 5444 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 i have a missile that is travelling along a velocity vector, and i want to rotate the missile so that it is always facing in the direction of the velocity vector what do i need to do? At the moment i am retreiving the modelview matrix and changing the z rotation for the model to the y component of the normalised velocity vector like this :

	Vector3d temp = velocity;

	float modelview[16];
	glGetFloatv(GL_MODELVIEW_MATRIX , modelview);

	modelview[8]  *= temp.y;
	modelview[9]  *= temp.y;
	modelview[10] *= temp.y;


But this just seems flatten the missile in the z axis and orient the plane to the vector perpendicular to the velocity vector. I have tried crossing the velocity vector with up (0,0,1) but this just gives the same results! Does anyone have any ideas or suggestions as to what i might be doing wrong?

Share this post

Link to post
Share on other sites
Yeah, don''t crosspost.

Other than that, use a matrix which contains the following data:
row 1: normalised direction vector (v1,v2,v3)
row 2: normalised "sideways" vector, e.g. (-v2,v1,v3)
row 3: up vector, you can calculate this by forming the crossproduct of rows 1 and 2.

- JQ

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!