POV-Ray : Newsgroups : povray.binaries.images : Helical SDF for Isosurfaces : Re: Helical SDF for Isosurfaces Server Time
4 Jan 2025 18:16:22 EST (-0500)
  Re: Helical SDF for Isosurfaces  
From: Tor Olav Kristensen
Date: 26 Dec 2024 13:30:00
Message: <web.676d9f804a98c6d672cba4c589db30a9@news.povray.org>
"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

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