POV-Ray : Newsgroups : povray.bugreports : atan2 problem : Re: atan2 problem Server Time
18 Jun 2024 08:28:50 EDT (-0400)
  Re: atan2 problem  
From: Dan Connelly
Date: 14 Oct 1998 22:57:11
Message: <36255656.A27A0A5A@flash.net>
I agree with Ron, sort of.  From a mathematical sense,
atan2(0,0) is multivalued in a real sense -- all real
numbers are potential solutions.  But in principle
atan2 is always multiply
defined in an integral sense (in 2 pi multiples), so the value
choices are all somewhat arbitrary.

Still, in practice, I agree it makes sense to assign zero to
this singularity.  There is little lost in doing so and
usually when one asks for atan2(0,0), one doesn't care much about
the answer as long as it exits, and zero is as good as
any other.

Ron Parker wrote:

> #macro my_atan2( YY, XX )
>   #if (YY = 0 & XX = 0 )
>     0
>   #else
>     atan2( YY,XX )
>   #end
> #end
> 
> and use that instead.

More compact is the trigraph:

#macro my_atan(Y,X)
  (((X = 0) & (Y = 0)) ? 0 : atan2(Y,X))
#end


-- 
http://www.flash.net/~djconnel/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.