POV-Ray : Newsgroups : povray.binaries.images : Helical SDF for Isosurfaces : Re: Helical SDF for Isosurfaces Server Time
4 Jan 2025 18:07:26 EST (-0500)
  Re: Helical SDF for Isosurfaces  
From: Tor Olav Kristensen
Date: 24 Dec 2024 22:20:00
Message: <web.676b78d74a98c6d61da4838d89db30a9@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> "Chris R" <car### [at] comcastnet> wrote:
> >...
> > I got it to work by making the following change:
> >
> > #declare natan2 = function(a,b) { select(a, 2*pi+atan2(a,b), atan2(a,b)) }
> > #declare Theta = function {((natan2 (y, z))/pi)*tau + x*tau}
> >
> > The problem is that atan2 has that discontinuity where it jumps from pi/2 to
> > -pi/2, ...
>
> Hi Chris
>
> I think that should be "from +pi to -pi".
>
> I would also suggest that you define your new atan2() function like this;
>
> #declare natan2 =
>     function(a, b) {
>         atan2(a, b) + select(a, 2*pi, 0)
>     }
> ;
>
> It makes what happens a little bit clearer at the expense of an extra addition.

I just noticed that both these variants have a little problem:
They have a discontinuity at a = -0

natan2(+1e-100, -1) = +3.141592653589793
natan2(     +0, -1) = +3.141592653589793
natan2(     -0, -1) = -3.141592653589793
natan2(-1e-100, -1) = +3.141592653589793

This variant does not have this problem:

#declare natan2 =
    function(a, b) {
        mod(atan2(a, b) + 2*pi, 2*pi)
    }
;

--
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.