# Find a direction of a object / body?

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

## Recommended Posts

Hi all, my brain is slowly dying as i try over and over again to solve this.

The result i am trynig to end up after all this is the AoA of a wing or plane. but ignoring that im stuck way before i get to that part.

to get the angle of attack i need the angle between the direction an object is moving and the direction an object is facing.

Now getting the objects facing direction is simple as im guessing that is found from the objects local axis.

But how do i get the objects moving direction?

Im using leadwerks engine which has newton game dynamics built in which im using

Included is a quick sketch to what im after.

[attachment=1487:direction.png]

Hope you can help.
Thanks
Andy

##### Share on other sites
Are you asking how to get the direction of motion? Or how to compute the angle between the direction of motion and the forward vector?

##### Share on other sites
Hi Jyk, well both to be honest, but i know i cant calculate the angle without knowing the direction of motion.

People tell me to use "get body velocity", but i dont see how this value is the direction of motion.

Thanks
Andy

##### Share on other sites

People tell me to use "get body velocity", but i dont see how this value is the direction of motion.

Well, it is :) Assuming we're talking about linear velocity of course.

The direction of the linear velocity vector for an object is the direction in which it's moving; the magnitude/length of said vector is the speed with which it's moving. So, I think the linear velocity is indeed what you're looking for.

I can't really comment on the physics part of the problem, but as for computing the (unsigned) angle between two 3-d vectors a and b, a robust method is as follows:

angle = atan2(length(cross(a, b)), dot(a, b))
The input vectors need not be unit length, and the only time this will fail is when one of the vectors has zero length or near zero length.

There may be more to the physics than simply computing this angle, but as far as computing the angle goes, the above is an effective method.

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 47
• ### Forum Statistics

• Total Topics
632636
• Total Posts
3007574
• ### Who's Online (See full list)

There are no registered users currently online

×