Possible to change Angular Velocity?

Official forum for the Chipmunk2D Physics Library.
Post Reply
bollu
Posts: 37
Joined: Tue Sep 14, 2010 4:33 am
Contact:

Possible to change Angular Velocity?

Post by bollu »

Hi all!

I create a Slide Joint which is attached on one side to a rogue body and on the other side to a movable body.
I apply impulses to move the movable body in all four directions.

When I press "left" (i.e apply impulse (-1,0) ) the movable body moves almost 3/4th to the top, and then falls down again. Ditto with the "right"(apply impulse (1,0)).

If I can add to angular velocity, this problem can be solved completely by holding a flag on which button was being pressed.If the button changes, I'll reduce the angular velocity. The problem is, I've been unable to find a function / method to change angular velocity of a body. :(

Will I have to compute the angular velocity?(shudder). I don't know how to so some math info would be cool. If it's possible, I'd like to know how.

Thanks all!

P.S I'm new to chipmunk and programming as a whole! I'm using C++, SDL for graphics n chipmunk for physics.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Possible to change Angular Velocity?

Post by slembcke »

http://files.slembcke.net/chipmunk/rele ... cs/#cpBody

You can do it the old way: body->w = angular_velocity
or using the setter function: cpBodySetAngVel(body, angular_velocity)

Either is fine.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
bollu
Posts: 37
Joined: Tue Sep 14, 2010 4:33 am
Contact:

Re: Possible to change Angular Velocity?

Post by bollu »

I tried changing angular velocity, but the body doesn't budge. Am I supposed to be using it in any other way? :( I want the body to rotate around a point. Any ideas?
Thanks Again!
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Possible to change Angular Velocity?

Post by slembcke »

The angular velocity is in radians per second, were you using the right units? Unless the object has a ridiculously low moment of inertia, it should work just as expected. If it did have such a low moment, other things would probably be messed up as well.

A rigid body always rotates around it's center of gravity. (like objects in free fall) If you want it to rotate around a different point, you need to apply some outside force or use a constraint.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
bollu
Posts: 37
Joined: Tue Sep 14, 2010 4:33 am
Contact:

Re: Possible to change Angular Velocity?

Post by bollu »

thanks selembeck! My units were wrong. Once that was changed, it's sailing smoothly!
Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests