# 3D Math

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

## 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 on other sites
Quote:
 Original post by VeslefrikkI 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 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 on other sites
Quote:
 Original post by VeslefrikkMotions 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 on other sites
I was ripping the hairs from my socket because I thought I had it but it just wouldnt work properly, and then I saw your reply. Inverted the matrix and now it works like a charm. :) ty

Stefan

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 103
• 11
• ### Forum Statistics

• Total Topics
632975
• Total Posts
3009669
• ### Who's Online (See full list)

There are no registered users currently online

×