POV-Ray : Newsgroups : povray.binaries.images : Helical SDF for Isosurfaces : Re: Helical SDF for Isosurfaces Server Time
4 Jan 2025 18:18:50 EST (-0500)
  Re: Helical SDF for Isosurfaces  
From: Chris R
Date: 24 Dec 2024 10:15:00
Message: <web.676acf024a98c6d63a6dfc485cc1b6e@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> 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, which happens along the edge you are looking at, and is made visible by
> > the switch in sign of the x value (x*tau).  The natan2 puts that discontinuity
> > at opposite ends of the value range, rather than in the middle and makes all of
> > the resulting angles positive (0-2*pi), and thus there is no abrupt switch when
> > x goes negative.
> >
> > -- Chris R
>
> Most Excellent, fine Sir!
> Some days I can see what needs to be done - other days it's more . . . opaque.
>
> I'm officially voting that such be made an internal function, or at least
> something available in functions.inc
>
> This could save a lot of people a lot of trouble in the future.
>
> Thank you,
>
> - BW
No problem.  I don't know how many times I have been tripped up by how atan2
works.

If you grab my libfn.inc from GitHub, https://github.com/carath63/povlibrary I
have defined f_normalized_atan2(x,y) already.  It would be good to have as a
builtin in a future version of pov-ray, but in the meantime, if you are using
any of my code in your scenes, it is already defined there.

-- Chris R


Post a reply to this message

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