Simulator Ignores RotationalDragCoefficient?

Topics: User Forum
Apr 22, 2009 at 5:41 PM
I'm working on a little game with Farseer, but I can't seem to get rotational drag to work. I've stepped through the code and I'm 100% positive I'm setting the body's rotational drag coefficient (to .995 so it should slow down at a good rate), but when the simulation starts, the box is given an initial angular velocity of 1 and never slows down. It should slow down and stop pretty quickly I would think.

Is there some other setting or value I need to be setting? I'm using BodyFactory to create the box with the proper width/height values so it should have the proper moment of inertia computed for it (I believe the factory does that, does it not?). Any ideas?
Coordinator
Apr 22, 2009 at 5:51 PM
The rotational drag coefficient should work. See the revolute joint demo here: http://www.physicspoweredgames.com/FarseerPhysics/Manual2.0.htm#_Toc213068492
It has rotational drag applied to it and it slows down.

The factories does indeed calculate the correct MOI for the shape. But that is not the problem.
You need a higher value than 0.995 to slow it down quickly. Try 1000 instead.
Apr 22, 2009 at 5:54 PM
Edited Apr 22, 2009 at 5:54 PM
Oh. I was thinking the values were 0-1 and were percentage based drag (like a frictional coefficient or restitution coefficient). Isn't linear drag on a 0-1 scale as well?

What is the scale the values are on? Arbitrary? Some other relationship with the object?
Coordinator
Apr 22, 2009 at 6:14 PM
The rotational drag is calculated like this (if I remember correctly, I will have to check it)

rd = av^2*sign(av) * (rdc*-1)

where rd is rotational drag, av is angular velocity and rdc is the rotational drag coefficient.
The value calculated is applied as torque to the body. The higher the angular velocity of the body, the more drag is applied to it.
Apr 22, 2009 at 6:24 PM
Hm. Ok.

Related to this I was tweaking the drag coefficient and it seems that if I go anything above 1000 (I was testing with 1500), my objects wind up getting an NaN value in a Math.Sin call involving angular velocity. Is this something I should be wary of or is there some way to know the values I'm inputting are safe? I can't have the game crashing due to NaNs. ;)
Coordinator
Apr 22, 2009 at 6:33 PM
Edited Apr 22, 2009 at 6:37 PM
It's really a balance of forces. It depends on all your other values. A 128x128 rectangle with a mass of 1 can take up to 100000 in rotational drag coefficient before blowing up. You will have to find the value that does what you desire and make sure that it does not cross the limit.
Then again, a value of 100000 is very high and would slow any kind of angular movement to a crawl.
Apr 22, 2009 at 8:24 PM
Fair enough. I think we'll just try to undershoot to avoid overshooting and crashing things. Thanks for all the help. :)