View Single Post
  #16   Spotlight this post!  
Unread 12-07-2011, 12:10
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
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.