Sign in to follow this  
AndyGil

Find a direction of a object / body?

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
[quote name='AndyGil' timestamp='1298536746' post='4778353']
People tell me to use "get body velocity", but i dont see how this value is the direction of motion.[/quote]
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 [i]a[/i] and [i]b[/i], a robust method is as follows:

[code]angle = atan2(length(cross(a, b)), dot(a, b))[/code]
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.

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