POV-Ray : Newsgroups : povray.general : I have a problem with atan2() : Re: I have a problem with atan2() Server Time
19 Apr 2024 15:09:58 EDT (-0400)
  Re: I have a problem with atan2()  
From: Le Forgeron
Date: 17 Oct 2021 08:01:30
Message: <616c109a$1@news.povray.org>
Le 17/10/2021 à 12:40, kurtz le pirate a écrit :
> 
> Hello,
> 
> I have a problem with  atan2(a,b) when b = zero.
> 
> The documentation on the page
> <http://www.povray.org/documentation/view/3.7.1/228/> says :
> 
> Arc-tangent of (A/B). Returns the angle, measured in radians, whose
> tangent is (A/B). **Returns appropriate value even if B is zero**
> 
> In my case, i get : Parse Error: Domain error in atan2!
> 
> So it's up to me to test if b=zero and return the appropriate value ?
> 
> 
> 
Looking at the code (parser_expression.cpp), it is a direct call to
atan2 function.
Povray parsed A, B, so from atan2 man page, A=y, B=x, *BUT* the code is
just defensive:

<pre>
   if (FTRUE(Val) || FTRUE(Val2))
                Val = atan2(Val,Val2);
       else
                Error("Domain error in atan2!");
      break;
</pre>

0 & 0 : Domain error. Which is correct as well as atan2 implementation
returning +pi/-0/-pi/+0 according to y,x being +/-0 at the same time.


Post a reply to this message

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