Geometry.c : dot2 function returning infinite values



Hi everyone,

I sometimes had an infinite loop during drawing of curved corners (when
they are close to flat angles), after much time spent to find whatever
what making the variables so wrong that it would loop eternally, I found
that the dot2 function was sometimes returning stange values (as it's
returning acos of something).

Maybe this only happens with microsoft compiler.
So, sometimes, when the result of the cos calculation from the two
vectors should be very close to 1, rounding (this happens every time we
make a float operation) of the value entered in the acos function may
make it be higher than 1.0 or lower than -1.0 .
The acos function from microsoft returns infinite (or something like
that) when the cos value is out of bounds, maybe other compilers doesn't
do this way to show an error there.
I corrected this behavior by making two simple tests (if (t>=1.0) t=1.0;
and same for -1.0) before calling the acos function in dot2 return.

This way, it may at least not loop forever, maybe then it is returning a
wrong angle value this way?

I'll give more information and more explanations tomorow if needed, I
hope I've been clear enough in my explanations.

Regards,

Clément Bègue




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]