POV-Ray : Newsgroups : povray.bugreports : atan2 problem Server Time
31 Oct 2024 21:30:29 EDT (-0400)
  atan2 problem (Message 1 to 4 of 4)  
From: Axel Baune
Subject: atan2 problem
Date: 14 Oct 1998 06:44:30
Message: <3624728B.C04D512F@neuro.informatik.uni-ulm.de>
Hi,

I've installed Pov 3.1a yesterday, and after a few tests I've
encountered a problem:

If you use atan2 the renderer reports a error in the case for the
Parameters A and B are zero (i.e. atan (0,0) ) In the previous version
of Pov (3.02) this error did't occur, here atan2(0,0) calculates to 0.

----------------------------------------------------------------
   POV INFO
----------------------------------------------------------------
Pov Version: PovRay for Windows v3.1a

----------------------------------------------------------------
   SYSTEM INFO
----------------------------------------------------------------
Operatingsystem: Windows 95 4.00.950 B OSR-2 with USB supply
Processor: AMD K6 300 3D Now!
Memory: 64 MB

----------------------------------------------------------------
  PROBLEM CODE
----------------------------------------------------------------

atan2(0,0)




--
------------------------------------------------------------------------------
Axel Baune                                            Phone:  +49 731 502 4242
Department of Neural Information Processing             Fax:  +49 731 502 4156
University of Ulm
89069 Ulm                            email: aba### [at] neuroinformatikuni-ulmde
Germany                            URL (privat): http://www.uni-ulm.de/~abaune
------------------------------------------------------------------------------


Post a reply to this message


Attachments:
Download 'us-ascii' (3 KB)

From: Ron Parker
Subject: Re: atan2 problem
Date: 14 Oct 1998 10:41:19
Message: <3624a9ff.0@news.povray.org>
On Wed, 14 Oct 1998 11:44:43 +0200, Axel Baune 
	<aba### [at] neuroinformatikuni-ulmde> wrote:

>If you use atan2 the renderer reports a error in the case for the
>Parameters A and B are zero (i.e. atan (0,0) ) In the previous version
>of Pov (3.02) this error did't occur, here atan2(0,0) calculates to 0.

This sounds like a bug in 3.02 rather than in 3.1.  atan2(0,0) doesn't make
any sense, either mathematically (what is 0/0?) or geometrically (what is
the angle of a vector of zero length?).  Simply put, it SHOULD report an 
error.  If you don't want it to, create a macro like

#macro my_atan2( YY, XX ) 
  #if (YY = 0 & XX = 0 )
    0
  #else
    atan2( YY,XX )
  #end
#end

and use that instead.


Post a reply to this message

From: Dan Connelly
Subject: Re: atan2 problem
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

From: Axel Baune
Subject: Re: atan2 problem
Date: 15 Oct 1998 08:23:23
Message: <3625DB37.3E314FE6@neuro.informatik.uni-ulm.de>
Dan Connelly wrote:

> #macro my_atan(Y,X)
>   (((X = 0) & (Y = 0)) ? 0 : atan2(Y,X))
> #end
>
> Ron Parker wrote:
>
> > #macro my_atan2( YY, XX )
> >   #if (YY = 0 & XX = 0 )
> >     0
> >   #else
> >     atan2( YY,XX )
> >   #end
> > #end
> >
> > and use that instead.
>

Thanks, I will try it and look if it will help.


--
------------------------------------------------------------------------------
Axel Baune                                            Phone:  +49 731 502 4242
Department of Neural Information Processing             Fax:  +49 731 502 4156
University of Ulm
89069 Ulm                            email: aba### [at] neuroinformatikuni-ulmde
Germany                            URL (privat): http://www.uni-ulm.de/~abaune
------------------------------------------------------------------------------


Post a reply to this message


Attachments:
Download 'us-ascii' (2 KB)

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