POV-Ray : Newsgroups : povray.advanced-users : What... the hell...? : Re: What... the hell...? Server Time
28 Jul 2024 10:30:35 EDT (-0400)
  Re: What... the hell...?  
From: Chris B
Date: 20 Mar 2006 08:06:10
Message: <441ea8c2$1@news.povray.org>
"Orchid XP v2" <voi### [at] devnull> wrote in message 
news:441ea0bb@news.povray.org...
>>>"atan2(A,B): Arc-tangent of (A/B). Returns the angle, measured in 
>>>radians, whose tangent is (A/B). Returns appropriate value even if B is 
>>>zero. Use atan2(A,1) to compute usual atan(A) function."
>>
>>
>>>Um... yeah, OK... so why does atan2(0, 0) give we a fatal parse error?
>>
>>
>>   Because the result is not defined. You are basically asking the
>> direction of a zero vector, which has none.
>
> I just thought the whole point of using atan2 was to _avoid_ divide by 
> zero errors.
>
> Sure, if the vector has a length of zero it has no defined direction. 
> OTOH, I would imagine in most cases it just wouldn't *matter* what number 
> the function returns in this case - just so long as it returns something, 
> rather than an error...
>
> Oh well.

Hi,

The easy workaround would be to put Slime's solution into your own macro 
e.g. Orchidatan2(A,B) returning the angle.
Then, if you've got a lot of atan2 calls you can just do a global replace.

Regard,
Chris B.


Post a reply to this message

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