POV-Ray : Newsgroups : povray.binaries.images : Helical SDF for Isosurfaces : Re: Helical SDF for Isosurfaces Server Time
2 Jan 2025 09:56:45 EST (-0500)
  Re: Helical SDF for Isosurfaces  
From: Kenneth
Date: 22 Dec 2024 10:20:00
Message: <web.67682a714a98c6d6e83955656e066e29@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
>
> POV-Ray absolutely drives me mad - on many occasions.
>
> I have a nice rifling cross section function, but for some reason - as of yet
> unknown to me, it behaves very badly when x is negative - as shown to the left
> of the origin.
>

I spent hours going through you code line by line, changing this-that-and
the-other, and I still cannot solve the subtle problem with the 'rifling' itself
(see the top image in the attachment.) I think that the only recourse-- given
the equations as-is-- is to just translate the problem area far into -x so that
it's 'outside' of your rifle barrel! Sorry that I can't offer a better
suggestion:
#declare Rifling = function {dist (x, y, z) - Helix (x/12 + 50 , y, z)
// The +50 moves it way into -x

The only thing I succeeded in doing was slightly simplifying your equations, to
make them easier to work with (for me.) [See below.] I think they behave a
*little* bit better, but not much.

But that's just part of the problem: The isosurface itself is behaving oddly,
with parts that are showing up as 'inside' and 'outside.' (I used an ambient 1
finish in the interior_texture to see this, along with a few changes to your
equations to show the problem 'writ large'.) It's an odd camera/isosurface
interaction. Even though the functions are producing infinite gradients, that
doesn't explain such a problem, IMO (but I could be wrong.) And the camera
position doesn't matter-- it always sees the 'inside' portions as being on the
'back half' of the the spirals. I thought the culprit might be the atan2
function in your Theta, but negating it does not help, it just changes the
'chirality' of the spiral.

In any case, here is my own simplified set of equations. The various values
interplay.  I think that the same rifling/spiral effect as your's can be gotten
by leaving the first 'tau' here as tau/1 (or just tau), and only changing the
2nd tau (plus  one or two other changes elsewhere to change the frequency and/or
'stretching'.) In this case, the 2nd tau's divisor needs to be greater than 1.0:

#declare Helix = function {select (mod (Theta(x, y, z), tau/1)
- tau/6, 0.308, 0.35)

my code:
#declare Theta = function {atan2 (y, z) + 1*x}  // change multiplier of x
// to change frequency, but leave as-is; similar to changing the x multiplier
// in Rifling function's Helix below

#declare dist = function {sqrt (y*y + z*z)}

#declare Helix = function {select (mod (Theta(x, y, z), tau/1) - tau/2, 0.15,
0.35)}
// change 2nd tau between tau/6 and tau/( > 1.0) to see change in ratio of
// lands to  grooves.

#declare Rifling = function {dist (x, y, z) - Helix (x*1 + 50, y, z)}
// try x*8, or x, or x*.6 , to see the 'squashing' or 'stretching' of
// the frequency

isosurface{
function {Rifling(x,y,z)}
contained_by{...}
threshold 0
 accuracy .000001 // 0.0001
 max_gradient 150
// no 'open'
--- etc ---
}

-----
BTW: While trying the fixes, I also came up with an alternate form of your Theta
function:  two different 'mating' functions that produce the rifling effect in
both +x and -x, and without  the original rifling's 'glitch' (but they don't
solve the odd isosurface problems.) But I haven't had any success yet in
*combining* these two functions into one, to get the same effect as the
individual ones. (AND, they only work when Helix's two tau's are tau/1 and
tau/2-- i.e., the square-wave situation; otherwise their spirals slightly
overlap near the the x axis.) Anyway, here they are (for use in my set of
equations)...

#declare Theta_1 = function {atan2 (y, z) +x + pi} // pi simply moves
// the spiral one-half 'revolution' into -x
#declare Theta_2 = function {-atan2 (y, z) -x} // nicely mates up with Theta_1


Post a reply to this message


Attachments:
Download 'be_rifling_with_problems--kw_1.jpg' (169 KB)

Preview of image 'be_rifling_with_problems--kw_1.jpg'
be_rifling_with_problems--kw_1.jpg


 

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