POV-Ray : Newsgroups : povray.general : I have a problem with atan2() : Re: I have a problem with atan2() Server Time
22 May 2024 07:40:06 EDT (-0400)
  Re: I have a problem with atan2()  
From: Alain Martel
Date: 18 Oct 2021 12:25:17
Message: <616d9fed$1@news.povray.org>
Le 2021-10-18 à 11:42, kurtz le pirate a écrit :
> On 17/10/2021 23:46, Cousin Ricky wrote:
>> ... Of course, the inverse tangent of A/0 is undefined, because A/0 is
>> undefined.  But a simple limits exercise, as well as the very definition
>> of the tangent of an angle, show that these undefined tangents
>> correspond to the angles pi/2 and -pi/2, and it is therefore useful to
>> pretend that they are valid.
>> The purpose of atan2() is to handle these special cases, by converting a
>> naive atan()'s argument into an ordered pair, thus allowing the would-be
>> inverse tangent of A/0 to be computed without having to divide by 0.  A
>> simple scene file shows that the *only* time atan2() fails with a domain
>> error is when *both* A and B are zero.  Of course, (0, 0) is an
>> indeterminate case, for which returning a value would be nonsensical.
>> ...
> Cousin Ricky is right about everything!
> And therefore, my problem is when A AND B are equal to zero.
> Lot of datas to deal with, the debugging will be long...
> (i'm working on the visualization of complex functions with domain 
> coloring)
Add a test to see if both A and B are zero, and replace that with some 
small value for B. It could be something like the following just before 
the call to atan2 :

#if (A=0 ! B=0) #declare B= 0.001; #end
... atan2(A,B) ...

Post a reply to this message

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