|
|
"Chris R" <car### [at] comcastnet> wrote:
>...
> Good catch!
>
> I actually modified f_normalized_atan2 as follows:
>
> #declare f_normalized_atan2 = function(x,y) {
> select(x,
> tau + atan2(x,y),
> pi,
> atan2(x,y)
> )
> }
>
> It's infinitesimally more efficient because you don't have to calculate
> atan2(+/-0,N), and gets rid of the mod arithmetic and addition where it isn't
> needed.
Sorry Chris,
It looked promising, but f_normalized_atan2(0, 1) returns pi instead of 0.
Rewriting it like this will solve that problem:
#declare f_normalized_atan2 =
function(x, y) {
select(
x,
atan2(x, y) + 2*pi,
select(y, pi, 0),
atan2(x, y)
)
}
;
Note that all these rewrites of the atan2() function does not trigger a "Domain
error", like atan2(0, 0) does when called outside a function.
--
Tor Olav
http://subcube.com
https://github.com/t-o-k
Post a reply to this message
|
|