Actual Direction?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Actual Direction?

Postby Gibbon » Wed Feb 23, 2011 6:29 am

Does NGD have a function or command to retrieve the actualy direction of a body?

for instance, if give a body a local foce along x and then whilst its moving i give add a force y how can i calulate its new direction?

And also, will the new direction still be the LOCAL X?

If not, how can i do this?

Thanks
Andy
Gibbon
 
Posts: 44
Joined: Tue Dec 15, 2009 5:18 am

Re: Actual Direction?

Postby Julio Jerez » Wed Feb 23, 2011 7:25 am

I believe that will be the matrix
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Actual Direction?

Postby Gibbon » Wed Feb 23, 2011 7:51 am

Hi Julio, could you elaborate a little on that?

How can i get the direction from the bodies matrix?

Thanks
Andy
Gibbon
 
Posts: 44
Joined: Tue Dec 15, 2009 5:18 am

Re: Actual Direction?

Postby ledahut » Wed Feb 23, 2011 8:48 am

If you want the direction vector from your matrix, this is the third column. (for example in identity matrix the vector direction is [0,0,1]).

If you want to know the direction where your body is moving (completely different from body direction).
Use newtonbodygetvelocity and then normalize this vector.


And also, will the new direction still be the LOCAL X?

What do you mean?
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Actual Direction?

Postby Gibbon » Wed Feb 23, 2011 9:01 am

Hi Ledahut, Thanks for the reply.

If you could, could you just help me understand the returned direction value of NewtonBodyGetVelocity, because that is what im wanting, but i dont undertsand what coordinate system this is using?

Going back to my originaly example if i have a body and i addforce(value) along the local X axis, and then i add a Y force to the object and then call the NewtonBodyGetVelocity, what coordinate system is the returned value on, beacause in world coords, its moving along the X at value and Y at value?

Ill explain a litt aboue what im trying to do.
If i have an object moving along an axis and add a torque to rotate the body say 45 degrees, i have it continue on its orignal path (which is what im trying to work out) but eventually that original path will (the actualy body moving direction) will catch up with the object FACING direction.

So im trying to calculate the moving direction of the body, not the way its facing (as thats easy), but the moving diretion.

But the confusing is coming because, using the 3d enigne im using and intergrated NGD it allows me to add forces to bodies locally. So if addforce to X and then some torque to rotate it and then some more X force , that X force will be different as the object rotated and so has the local X of the body, so how do i then match up the returned values from NewtonBodyGetVelocity, that i belive will be in WORLD coords?

Thanks
Andy
Gibbon
 
Posts: 44
Joined: Tue Dec 15, 2009 5:18 am

Re: Actual Direction?

Postby ledahut » Wed Feb 23, 2011 9:35 am

What is your 3d engine? Maybe the author use a set/get in the body class.

By default newton return velocity value in world space.
It will be better if you call this function just before a NewtonUpdate.

If you can get the global velocity you will get a vector but it will not be normalized by default.
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Actual Direction?

Postby Gibbon » Wed Feb 23, 2011 9:39 am

Thanks again for the help ledahut.

Ive just realised that the engine can return the NewtonBodyGetVelocity locally and globally to the body. (leadwerks is the engine)

So with that in mind it brings me onto my next question, which you partially mentioned in your last post.

The return local velocity? Well isnt that a velocity as apposed to a direction, that i could use to measure an angle with?

For instance, if i now have the direction the body is moving in and the direction the body is facing i would like to measure the angle bewteen them.

Do i have to create a vector from that bodyvelocity?

Thanks
Andy
Gibbon
 
Posts: 44
Joined: Tue Dec 15, 2009 5:18 am

Re: Actual Direction?

Postby ledahut » Wed Feb 23, 2011 9:51 am

The return local velocity? Well isnt that a velocity as apposed to a direction, that i could use to measure an angle with?

The return local velocity will have the same length of global velocity but in body_space (the axis x y z of the vector will be relative to the matrix orientation of your body).

Then yes I think you can 'measure' an angle with another vector. But remember that the vectors must be in the same space, else the result won't mean anything.

Do i have to create a vector from that bodyvelocity?

Depends of what you want to do with. :)
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Actual Direction?

Postby Gibbon » Wed Feb 23, 2011 9:59 am

Thanks ledahut, although i feel alot closer to understadning this theres still one thing im not entirly sure about?

And im sure its just me not "seeing" it.

But if NewtonBodyGetVelocity returns the "velocity" of the axis, thats isnt just the "direction" is it?

What i mean is, if i was to measure the angle between the body facing direction and the body moving direction ( NewtonBodyGetVelocity), ill get strange results with the NewtonBodyGetVelocity returned value? Do i need to do anything else to it?

Thanks
Andy
Gibbon
 
Posts: 44
Joined: Tue Dec 15, 2009 5:18 am

Re: Actual Direction?

Postby ledahut » Wed Feb 23, 2011 10:15 am

ill get strange results

The body facing direction is in world space (the local facing direction is always [0,0,1]).

If you want the angle between moving direction and facing direction you maybe need to normalize the vector given by NewtonBodyGetVelocity.
I don't know how To measure angle between vector, but there is example on the web.
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron