Archived

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

Turning a ship towards a point in space...

This topic is 5129 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

What if there''s an object sitting in space with a position and rotation... now say that I want the ship to turn toward any point in 3d space, how would I do that? and please realize that the ship has a rotation vector (x,y,z). thanks

Share this post


Link to post
Share on other sites
that depends on what your rotation vector is. if it is a collection of three angles then delete it and forget the approach, it will throw away the order of applied rotations which is important to get the right result.

next: do you want to turn or just place it correctly? the latter would be easier but is usually not too useful. so you need two things: angle and axis. the axis should be the crossproduct between your current view direction and the vector from your position to the target point. the angle will be the inverse cos of the dotproduct (normalize them before). things will get more complicated if you dont just want to look at a point but also want a certain orientation.

another way would be transforming your current and target matrix to quaternions which are nicer to interpolate but introduce more overhead for converting back and forth.

Share this post


Link to post
Share on other sites
If I understand your need correctly - you should be able to use the same methodology as camera pointing. It is basic vector geometry to point something at something else (ie, get the angles between them).

There are loads of articles and tutorials on cameras and vectors. Check out the articles on this site or google it.



"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan

Share this post


Link to post
Share on other sites
Make this ship have a state describing its rotational velocity, then just set that velocity to make it turn toward the point. On each frame draw/ time elapse rotate the ship according to the rotational velocity.

Pat

Share this post


Link to post
Share on other sites
There is a thread here which deals with 3D enemy spaceship control. It discusses various techniques.

http://www.gamedev.net/community/forums/topic.asp?topic_id=180533

Share this post


Link to post
Share on other sites