Sign in to follow this  
Veslefrikk

3D Math

Recommended Posts

I have objects in my 3d scene(ships) that I want to turn towards eachother, Im not sure how to do this. I use matrixes for my rotations. What I need is to have a vector interpolating its rotation so its faces a given point in 3d space. Help is much appriciated :) Stefan

Share this post


Link to post
Share on other sites
Quote:
Original post by Veslefrikk
I have objects in my 3d scene(ships) that I want to turn towards eachother, Im not sure how to do this. I use matrixes for my rotations. Help is much appriciated :)

Stefan
There are a number of ways to do this, ranging from potential functions to simple vector math.

A few questions:

1. How is the motion of your ships handled? Is it more or less 'ad hoc', or are you using a physics engine of some sort?

2. How are your object orientations represented? You mentioned matrices, but are the rotation operations applied directly to the rotation matrix? Or is there an intermediate representation, such as Euler angles?

3. Is the motion of the ships 'free' (6DOF), or is it constrained in some way?

Share this post


Link to post
Share on other sites
Motions of the ships are very basic atm, I will write some simple physics later on.
I do my rotation by adding the new rotation to a stored matrix and then keep that matrix orthoganised.
And there is no constrains on the ships whatsoever in terms of movement or rotation.

Thanks for quick response.


Stefan

Share this post


Link to post
Share on other sites
Quote:
Original post by Veslefrikk
Motions of the ships are very basic atm, I will write some simple physics later on.
I do my rotation by adding the new rotation to a stored matrix and then keep that matrix orthoganised.
And there is no constrains on the ships whatsoever in terms of movement or rotation.
Here is one way you could proceed (this is the simplest method I can think of at the moment):

1. Transform the target position into the local space of the ship (by multiplying the target position with the ship's inverse model matrix).

2. Check the components of the transformed point corresponding to the ship's local-space side and up vector to see if the target is to the left or right, and whether it is 'up' or 'down'.

3. Apply local pitch and yaw as appropriate.

This may need fine tuning, but the basic idea should be sound.

Let me know if you have any questions.

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