|
Re: Cartesian to angle
atan2(x,y) gives +/-pi clockwise from the +Y axis. That puts the discontinuity on the -Y axis, which then requires you to add conditional logic to fix it. There's a better way.
BTW, concerning atan2(0,0), many modern implementations, such as the microcode in the FP unit of the Pentium*, helpfully return zero when both arguments are zero. Does anyone know what the FRC versions of LabVIEW, C++, and Java do?
* here's a short test code written in Delphi:
USES windows, sysutils;
Function FPatan2(y : extended; x : extended): Extended;
Assembler;
asm fld [y] ; fld [x] ; fpatan end ;
BEGIN
write(FPatan2(0,0),' Pentium FP processor built-in microcode');
END.
Last edited by Ether : 12-07-2011 at 12:27.
|