From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>

Date: Thu 14 Apr 2005 - 22:15:39 EST

Date: Thu 14 Apr 2005 - 22:15:39 EST

Clément Calenge <calenge@biomserv.univ-lyon1.fr> writes:

> Dear all,

*>
**> I've got a problem with the function atan2. For a couple of
**> coordinates x and y,
**> This function returns the angle between the vector of coordinates (x,
**> y) and the
**> abscissa axis, i.e. it is the same as atan(y/x) (as indicated on the
**> help page).
**> If we consider the vector with coordinates x = 0 and y = 0, we have
**> the following result:
**>
**> > atan(0/0)
**> [1] NaN
**>
**> This is expected. However:
**>
**> > atan2(0,0)
**> [1] 0
**>
**> Instead of a missing value, the function atan2 returns an angle equal
**> to 0 radians.
**> I've searched through the help pages, the FAQ and the forum, but I
**> did'nt find
**> any explanation to this result. Does anyone know if this behavior is
**> expected, and
**> why ?
**> Thank you for any clues.
*

Yes, it is expected. R just copies what the C library function does, but there is actually a rationale:

http://www-sbras.nsc.ru/cgi-bin/www/unix_help/unix-man?atan2+3

Briefly: You don't get a natural conversion to spherical coordinates and back without this convention.

-- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlReceived on Thu Apr 14 22:20:18 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:31:10 EST
*