btEquals question?

ill
Posts: 7
Joined: Sat Jan 29, 2011 4:14 am

btEquals question?

Post by ill »

I'm pretty confused about the btEquals function.

This is the code from btScalar.h.

Code: Select all

SIMD_FORCE_INLINE bool	btEqual(btScalar a, btScalar eps) {
	return (((a) <= eps) && !((a) < -eps));
}
I can't find any documentation on this function. All I know is it's called btEquals. I first thought it compared two btScalars for equality. After a LOOOT of debugging I finally noticed this function doesn't appear to work the way it should. First of all, the second argument is eps, for epsilon?

I was using it to compare 29.53 and 31.04.

a <= eps returns true since 29.53 is less than or equal to 31.04.

a < -eps returns false since 29.53 is not less than -31.04. Then there's the not operator, turning this into true. This in effect returns true for 29.53 being equal to 31.04.

I'm really confused as to how this function is supposed to be used. I'd understand if it took btSclar a, btScalar b, then btScalar eps for the epsilon between them or something.

Before I actually looked at its code I assumed it worked something like

Code: Select all

btFuzzyZero(a - b);
snake5
Posts: 13
Joined: Tue Mar 01, 2011 4:04 pm

Re: btEquals question?

Post by snake5 »

Looks like it tests whether "a" is no more than "eps" units away from zero. I don't see any magic in the code except the name of the function. :D
I guess a better name for this would be btNearZero or something like that. :P
ill
Posts: 7
Joined: Sat Jan 29, 2011 4:14 am

Re: btEquals question?

Post by ill »

Yeah that looks about right.

I really wish the documentation in bullet physics was better. It's pretty much nonexistant in the API docs.