btAtan2Fast in getHingeAngle returns "-1.#IND000" [solved]

TheNinja
Posts: 4
Joined: Thu Dec 06, 2007 11:59 am
Location: Austria

btAtan2Fast in getHingeAngle returns "-1.#IND000" [solved]

Post by TheNinja »

Hello,

I'm using a hinge constraint for a servo. You can see it in this image. The small part and the big part are used for the hinge and they are rotating around the global y-axis (actually I used (0,0,1), because there are some rotations involved). I got the following values for the axis when I called getHingeAngle():

Code: Select all

const btVector3 refAxis0(-0.0f,-1.0f, 0.0f);
const btVector3 refAxis1( 0.0f, 0.0f,-0.0f);
const btVector3 swingAxis(0.0f, 0.0f, 0.0f);
btScalar Dot1 = swingAxis.dot(refAxis0);
btScalar Dot2 = swingAxis.dot(refAxis1);
btScalar tanRes = btAtan2Fast( Dot1, Dot2);
This results in tanRes = -1.#IND000. Changing from btAtan2Fast() to btAtan2() results in tanRes = 0.
But the 0 isn't changing (-> I don't get a proper angle), although the small part is rotating as it should.
Any ideas how to get the angle calculation to work again?

Thanks!
Last edited by TheNinja on Tue Jan 08, 2008 12:19 pm, edited 1 time in total.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: btAtan2Fast in getHingeAngle returns Errorcode "-1.#IND000"

Post by Erwin Coumans »

TheNinja wrote:

Code: Select all

const btVector3 refAxis0(-0.0f,-1.0f, 0.0f);
const btVector3 refAxis1( 0.0f, 0.0f,-0.0f);
const btVector3 swingAxis(0.0f, 0.0f, 0.0f);
[...]
Can you make sure all axis have non-zero length? In your example, refAxis1 and swingAxis are zero length.

Hope this helps,
Erwin
TheNinja
Posts: 4
Joined: Thu Dec 06, 2007 11:59 am
Location: Austria

Re: btAtan2Fast in getHingeAngle returns Errorcode "-1.#IND000"

Post by TheNinja »

Thanks for the reply Erwin!
I worked around it by calculating the axis, which resulted in something like (0.0003, 0.998, 0.0012). This is different enough from my hard coded input (0, 1, 0) to get the angles working again.

I find it quite odd that (0, 1, 0) is not working, but then again every math has some limitations and it's easy to work around this one. -> It's fine with me.