Page 1 of 1

Possible to change Angular Velocity?

Posted: Thu Sep 30, 2010 11:18 am
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.

Re: Possible to change Angular Velocity?

Posted: Thu Sep 30, 2010 12:03 pm
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.

Re: Possible to change Angular Velocity?

Posted: Thu Sep 30, 2010 10:44 pm
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!

Re: Possible to change Angular Velocity?

Posted: Fri Oct 01, 2010 8:12 am
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.

Re: Possible to change Angular Velocity?

Posted: Sat Oct 02, 2010 9:44 am
by bollu
thanks selembeck! My units were wrong. Once that was changed, it's sailing smoothly!