the direction an object is moving

Official forum for the Chipmunk2D Physics Library.
Post Reply
brcimo
Posts: 2
Joined: Mon Aug 17, 2009 5:46 pm
Contact:

the direction an object is moving

Post by brcimo »

I was wondering how to find out the direction/angle a body is moving in, not necessarily the angle it is facing. So if a ball is flying in the air, I want to know what direction it is moving, not the angle it is pointed in. Sorry if this has already been covered, but I couldn't find anything in a search about it. Thank You for the help!
brcimo
Posts: 2
Joined: Mon Aug 17, 2009 5:46 pm
Contact:

Re: the direction an object is moving

Post by brcimo »

It seems I was able to solve this myself, here's what I came up with:

Code: Select all

float tAngle;
tAngle = cpvtoangle(sBody->v);
Seems to give me the right angle anyway. Thoughts?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: the direction an object is moving

Post by slembcke »

That is correct, however the result is undefined when the object is not moving. Be careful of that.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests