btAtan2Fast too approximate

marcimatz
Posts: 34
Joined: Fri Sep 18, 2009 5:41 am

btAtan2Fast too approximate

Post by marcimatz »

Hello,

In the last few days I have been wondering why my PID position controller doesn't work as nicely as it should with hinges. I finally tracked down my problem to the "btAtan2Fast" function used in the "btHingeConstraint::getHingeAngle".
When I replaced the "btAtan2Fast" call with a simple "atan2" call, my position controller worked like a charm.
I didn't measure it, but it seems that the "btAtan2Fast" function has a precision of +-4 degrees in some situations. My question is: is the speed increase of "btAtan2Fast" really worth the reduction in precision?

Thanks for any insight!
User avatar
rponomarev
Posts: 56
Joined: Sat Mar 08, 2008 12:37 am

Re: btAtan2Fast too approximate

Post by rponomarev »

Yes, btAtan2Fast() is not precise.
I replaced it by btAtan2() as of r1833
Hopefully it will not hurt performance (unless you have several thousand of hinges in your scene)

Thanks for pointing on that,
Roman
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: btAtan2Fast too approximate

Post by Flix »

rponomarev wrote:

I replaced it by btAtan2() as of r1833
AFAIK there are still some btAtan2Fast calls in btConeTwistContraint.cpp.

(Or maybe you can temporary replace it in btScalar.h and make it call btAtan2 to avoid these problems, in case somebody will find a better implementation in the future).

Regards,
Flix