Topic : atan2(y,x)

Forum : 8051

Original Post
Post Information Post
July 3, 2008 - 12:09pm
Guest

The atan2 maths function does not seem to handle the singularity correctly.

The whole point of atan2(y,x) as opposed to atan(y/x), is to be able to give the correct angle (+/- pi/2) when x is zero, and the parameter to atan would become infinite.

However I find that the BCD(float) version (?atan2f) actually returns zero if the second parameter is zero, and the IEEE version (?atan2) returns NAN.

I have tested it over the specified range of -pi...pi by
y = sin(a);
x = cos(a);
b = atan2( y, x);
then comparing a with b. For all values other than +/- pi/2 it correctly returns the original angle, (except that pi returns -pi, which is understandable).

I am using Ride BN 746-51

regards

Tim Jackson

Replies
Post Information Post
+1
0
-1
July 4, 2008 - 9:00am
Guest

ok. This is old stuff for us, but we will fix it.
I guess you are implementing your calculator.
Thanks for the report,

Francis

+1
0
-1
July 7, 2008 - 7:14pm
Guest

Thanks. I'm actually implementing a CNC controller with USB flash disk on the uPSD3434.
It's a bit worrying when cutting an arc and the tool suddenly jumps to the centre of the curve!
I've put in a macro solution for now, which seems to work ok.

Tim

+1
0
-1
July 9, 2008 - 11:39am
Raisonance Support Team

The bug is fixed in the libraries.
Fix will be available in the next release.

Stéphane