POV-Ray : Newsgroups : povray.newusers : Isosurface and f_spiral - bug or feature? Server Time
28 Mar 2024 07:19:48 EDT (-0400)
  Isosurface and f_spiral - bug or feature? (Message 2 to 11 of 23)  
<<< Previous 1 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Bald Eagle
Subject: Re: Isosurface and f_spiral - bug or feature?
Date: 24 Sep 2017 15:00:01
Message: <web.59c80047808cf4025cafe28e0@news.povray.org>
"Ronkhar" <nomail@nomail> wrote:

I'm going to speculate that the darkness arises from the angle of viewing
_through_ the highly filtered texture.   The more you look through, the darker
it gets.   At extreme angles, this may add up quickly and get VERY dark.

http://life.nthu.edu.tw/~labcjw/BioPhyChem/Spectroscopy/beerslaw.htm


>    texture{pigment{ color Red filter 1 }}


> Problem 2: Near the center, the exterior part of the spirals end with a straight
> line, where I was expecting the curve to continue.

This might [also] be a matter of perspective.
I'd suggest rotating your isosurface or repositioning the camera to see if it
goes away, and what you _think_ you should see is actually there, or an illusion
or unexpected result of the texture and/or lighting.
(align your spiral so that it is symmetric around the y-axis)

I might also move the light source, and perhaps add one or two more.

http://3drender.com/light/3point.html


Post a reply to this message

From: omniverse
Subject: Re: Isosurface and f_spiral - bug or feature?
Date: 24 Sep 2017 16:25:01
Message: <web.59c81409808cf4029c5d6c810@news.povray.org>
"Ronkhar" <nomail@nomail> wrote:
>
> I'm currently playing with the isosurface and f_spiral function, and I'm
> experiencing 2 curious artifacts.

I looked at the f_spiral in source code but couldn't be sure where it creates
the initial sphere, which apparently is merely the result of the diameter used
for spiral arm.

The outer straight edge might be a result of couple things. One is that as it
tapers off due to overall size given to it there's a clipping (or rather
differencing) effect because of the "outer size" parameter.
And the other might simply be related to max_gradient.

At least that's my guess.

Bald Eagle makes a good point about the filtered transparency, although the
problem here seems to be how this spiral function does indeed create a sphere at
the origin. Same seen in version 3.6.2 and the latest 3.8 alpha.


Post a reply to this message

From: Kenneth
Subject: Re: Isosurface and f_spiral - bug or feature?
Date: 25 Sep 2017 03:10:01
Message: <web.59c8aa9f808cf402883fb31c0@news.povray.org>
"omniverse" <omn### [at] charternet> wrote:

>
> I looked at the f_spiral in source code but couldn't be sure where it creates
> the initial sphere, which apparently is merely the result of the diameter used
> for spiral arm.

That seems to be the case, just from experimenting with the OP's test code. The
sphere diameter is some percentage of the 'thickness' parameter (maybe 100%,
although it's hard to tell.) That sphere makes me wonder what it's purpose is--
maybe it hides some other kind of anomoly at the beginning of the spiral ;-)
Otherwise, it would seem natural for the spiral shape to both begin and end at a
nice sharp point.
>
> The outer straight edge might be a result of couple things. One is that as it
> tapers off due to overall size given to it there's a clipping (or rather
> differencing) effect because of the "outer size" parameter.

Agreed (and which is different from the isosurface's own contained_by sphere.)

> And the other might simply be related to max_gradient.

Nope, that doesn't affect the 'inner' straight-line anomoly. It's actually just
an optical illusion (which took me awhile to figure out-- I had to rotate the
spiral around in an animation, to see the true cause.) The 'straight line' is
just the join-line between the OP's 'square' spiral shape and the center sphere,
where they blend together ('blend' is probably the wrong word.) In other words,
it just a result of the different geometries. It is naturally more pronounded as
the 'thickness' value increases...and actually appears worse when using a
'round' shape for the spiral. The OP's original image of multiple stacked
spirals (with transmit 1 in the colors, as well as the camera position) was
making the problem hard to see.

Here's my re-worked test code, with only a few minor changes. It's a close-up of
the center sphere. Comment-out both of the rotations at the end, to see the
'straight-line' effect.

#version 3.7;
global_settings { assumed_gamma 1 }
#include "colors.inc"
#include "transforms.inc"

light_source { <-1,8,3> color White}

camera {
  perspective
  location  <0, 12, 0>
  look_at   <0, 0, .1>
  right     x*image_width/image_height
  angle 4 // 15 or 4
}

plane {y, -20 pigment { checker Grey, White}}

isosurface{ function{f_spiral(x,y,z,
   6,   // distance between windings-- 6
   .2, // thickness-- .2
   2.0,    // outer radius of the spiral-- 2
   0,  // not used
   0,  // not used
   0   // cross-section type-- 0 for square. Or 1.0 for round.
   )}
   accuracy 0.001
   threshold 0
   max_gradient 40
   contained_by{sphere{<0,0,0>,3}} // [originally <0,0,0>,15 -- too big]
   texture{pigment{ color Red}}
   no_shadow
   rotate 30*x
   rotate 30*z
   }


Post a reply to this message

From: Kenneth
Subject: Re: Isosurface and f_spiral - bug or feature?
Date: 25 Sep 2017 03:35:01
Message: <web.59c8b089808cf402883fb31c0@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
>
> The OP's original image of multiple stacked
> spirals (with transmit 1 in the colors...

Sorry; I meant filter 1 in the colors.

And the rotations at the end should be...
rotate 30*x
rotate -30*z
....for a better illustration of the effect.. which also shows some additional
straight-line segments or surfaces. I have no clue as to what they are; more
optical illusions?


Post a reply to this message

From: Ronkhar
Subject: Re: Isosurface and f_spiral - bug or feature?
Date: 29 Sep 2017 10:35:00
Message: <web.59ce596f808cf402832bdcda0@news.povray.org>
Hello,
I thank all three of you for your helpful answers.

I watched the animation with the rotations suggested by Kenneth and it's really
useful in seing the real shape of the spiral. I'll try to remember this trick in
the future.

Regarding omniverse message, where did you find the f_spiral source code,
please?
I searched *.ini *.pov and *.inc files for "f_spiral" and "internal", but the
occurrences did not look like a mathematical definition of the spiral.
Did I miss something?
Or is it in the source code located at github and it's only in binary form in
the windows executable?

Bye
Ronkhar


Post a reply to this message

From: Bald Eagle
Subject: Re: Isosurface and f_spiral - bug or feature?
Date: 29 Sep 2017 11:55:00
Message: <web.59ce6c33808cf402c437ac910@news.povray.org>
"Ronkhar" <nomail@nomail> wrote:

> Or is it in the source code located at github and it's only in binary form in
> the windows executable?

It's in the source code.
There are a lot of very cool functions in there, and lots to learn just by
seeing some of them are implemented.


Post a reply to this message

From: Bald Eagle
Subject: Re: Isosurface and f_spiral - bug or feature?
Date: 29 Sep 2017 13:00:01
Message: <web.59ce7b04808cf402c437ac910@news.povray.org>
This is from the 3.7-stable source:

DBL f_spiral(FPUContext *ctx, DBL *ptr, unsigned int) // 64
{
 DBL r, r2, th, temp;
 /* spiral shape                *
  *                             */
 r = sqrt(PARAM_X * PARAM_X + PARAM_Z * PARAM_Z);
 if ((PARAM_X == 0) && (PARAM_Z == 0))
  PARAM_X = 0.000001;
 th = atan2(PARAM_Z, PARAM_X);
 r = r + PARAM(0) * th / TWO_M_PI;
 r2 = fmod(r, PARAM(0)) - PARAM(0) * 0.5;

 if (PARAM(5) == 1)
  r2 = sqrt(r2 * r2 + PARAM_Y * PARAM_Y);
 else if (PARAM(5) != 0)
 {
  temp = 2 / PARAM(5);
  r2 = pow((pow(fabs(r2), temp) + pow(fabs(PARAM_Y), temp)), 1. / temp);
 }
 else
  r2 = max(fabs(r2), fabs(PARAM_Y));

 r = sqrt(PARAM_X * PARAM_X + PARAM_Y * PARAM_Y + PARAM_Z * PARAM_Z);

 return (-min(PARAM(2) - r, PARAM(1) - min(r2, r)));
}


Post a reply to this message

From: omniverse
Subject: Re: Isosurface and f_spiral - bug or feature?
Date: 29 Sep 2017 13:45:02
Message: <web.59ce866f808cf4029c5d6c810@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> This is from the 3.7-stable source:
>
> DBL f_spiral(FPUContext *ctx, DBL *ptr, unsigned int) // 64

I'm glad you posted it, I was afraid of breaking a law about posting program
code. LOL

Still don't see where it produces the central sphere, not that I would be able
to guess anyhow but I thought maybe the r= before all the 'if' switching takes
place. Except r looks like the spiral shape not sphere size...?

I shouldn't even try to guess.  :)


Post a reply to this message

From: Bald Eagle
Subject: Re: Isosurface and f_spiral - bug or feature?
Date: 29 Sep 2017 15:15:00
Message: <web.59ce9b17808cf402c437ac910@news.povray.org>
DBL f_spiral(FPUContext *ctx, DBL *ptr, unsigned int fn); // 64
.....
{ f_spiral,                  6 + 3 }, // 64
.....

DBL f_spiral (FPUContext *ctx, DBL *ptr, unsigned int) // 64

{
     DBL r, r2, th, temp;

     r = sqrt(PARAM_X * PARAM_X + PARAM_Z * PARAM_Z);
     if ((PARAM_X == 0) && (PARAM_Z == 0))
          PARAM_X = 0.000001;
          th = atan2(PARAM_Z, PARAM_X);
          r = r + PARAM(0) * th / TWO_M_PI;
          r2 = fmod(r, PARAM(0)) - PARAM(0) * 0.5;

     if (PARAM(5) == 1)
          r2 = sqrt(r2 * r2 + PARAM_Y * PARAM_Y);

     else if (PARAM(5) != 0)
     {
          temp = 2 / PARAM(5);
          r2 = pow((pow(fabs(r2), temp) + pow(fabs(PARAM_Y), temp)), 1. / temp);
     }

     else
          r2 = max(fabs(r2), fabs(PARAM_Y));
          r = sqrt(PARAM_X * PARAM_X + PARAM_Y * PARAM_Y + PARAM_Z * PARAM_Z);

     return (-min(PARAM(2) - r, PARAM(1) - min(r2, r)));
}


I'd say that the very last r defines sqrt of x-squared + y-squared + z-squared -
which is the implicit / closed form of the surface of a sphere.
So, I'd start looking there....

Maybe rewrite it out in SDL so it's easier to play with.


Post a reply to this message

From: Bald Eagle
Subject: Re: Isosurface and f_spiral - bug or feature?
Date: 29 Sep 2017 23:20:01
Message: <web.59cf0ca7808cf4025cafe28e0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

Alright kids,
I puzzled out the basic conversion from cpp to SDL, and then had to envision how
POV-Ray computes the isosurface (notice the whole internal function just returns
a single scalar value) and emulate that.

First off, this following bit seems to be related to the culprit:

> I'd say that the very last r defines sqrt of x-squared + y-squared + z-squared -
> which is the implicit / closed form of the surface of a sphere.
> So, I'd start looking there....

If you take a look over at
http://www.econym.demon.co.uk/isotut/builtin1.htm
at
http://www.econym.demon.co.uk/isotut/std007.jpg
you'll see that Mike Williams' render of this function shows the same odd sphere
at the center.

ALSO notice that that last parameter is what is used to determine the
cross-sectional shape of the spiral.

> Maybe rewrite it out in SDL so it's easier to play with.

I did, and I will post the results in p.b.i to show the difference between the
round cross section (0) and the square (1)

Other things to notice to get a basic understanding about how the isosurface
gets plotted, is that the code loops/steps through "all" the points in the box
and evaluates the isosurface function.  If that value is zero (or less than
'epsilon' (STEP) ) then it applies the designated texture, lighting, etc (plots
a sphere)

The bigger the box, the more points have to be looped through to run through the
isosurface formula, and the longer the loop takes.
The more complicated / slower the formula is to evaluate, the longer the loop
takes.

That's the basis of why isosurfaces are so slow to evaluate.

If I have more time, I'll see if I can refine it a bit, and maybe do a Paul
Nylander meshification version, and perhaps a wireframe version or two.


Post a reply to this message

<<< Previous 1 Messages Goto Latest 10 Messages Next 10 Messages >>>

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