POV-Ray : Newsgroups : povray.newusers : Newbie isosurface question Server Time
29 Jul 2024 14:16:01 EDT (-0400)
  Newbie isosurface question (Message 1 to 6 of 6)  
From: mwhidden
Subject: Newbie isosurface question
Date: 13 Dec 2005 13:40:00
Message: <web.439f141b6977d092c739b8ad0@news.povray.org>
POV-Ray 3.6.1a.icl8

It seems to me that in an isosurface, one can substitute sin(f_th(x,y,z))
for x and cos(f_th(x,y,z)) for z, and that bears out in simple testing.

Next I try to construct a cylinder via (x*x + z*z - 1), which works like a
champ. Then when I substitute the sin/cos of f_th() for x and z, it goes
all hooey and I get a solid box with a bunch of speckles, regardless (it
seems) of max_gradient settings.

Anyone have any idea why?

Scene files follows, render at the resolution of your preference:

-----------------------------------------

#include "colors.inc"
#include "functions.inc"

camera {
  location  <2.0, 10.5, -10.0>
  look_at   <6.0, 0.0,  0.0>
}

light_source { <-30, 30, -30>  color rgb 1 }

plane { y, 0
  pigment { color rgb <0.7,0.5,0.3> }
}

#declare XTest= function{x}

#declare SinTest= function{ sin(f_th(x,y,z))}

#declare ZTest= function {z}

#declare CosTest= function{ cos(f_th(x,y,z))}

#declare XZTest= function{pow(XTest(x,y,z),2) +
                          pow(ZTest(x,y,z),2) - 1}

#declare SinCosTest= function{ pow(SinTest(x,y,z),2) +
                               pow(CosTest(x,y,z),2) - 1}

#declare Funcs = array[6] {function{XTest(x,y,z)},
                           function{SinTest(x,y,z)},
                           function{ZTest(x,y,z)},
                           function{CosTest(x,y,z)},
                           function{XZTest(x,y,z)},
                           function{SinCosTest(x,y,z)}}

#local i=0;
#while(i < 6)
        isosurface{
                function {Funcs[i](x,y,z)}
                contained_by {box {-1, 1}}
                open
                evaluate 0.6, 33, .7
                texture{pigment{color White}}
                translate i*3*x
        }
        difference{ box{-1,1} box {<-2,.1,-2>,2}
                    texture{pigment{color Blue}}
                    translate i*3*x}
        #local i=i+1;
#end


Post a reply to this message

From: Mike Williams
Subject: Re: Newbie isosurface question
Date: 13 Dec 2005 15:06:32
Message: <nFH6uAA$mynDFwqU@econym.demon.co.uk>
Wasn't it mwhidden who wrote:
>POV-Ray 3.6.1a.icl8
>
>It seems to me that in an isosurface, one can substitute sin(f_th(x,y,z))
>for x and cos(f_th(x,y,z)) for z, and that bears out in simple testing.
>
>Next I try to construct a cylinder via (x*x + z*z - 1), which works like a
>champ. Then when I substitute the sin/cos of f_th() for x and z, it goes
>all hooey and I get a solid box with a bunch of speckles, regardless (it
>seems) of max_gradient settings.
>
>Anyone have any idea why?

Although the function "x" and the function "sin(f_th(x,y,z))" are zero
at the same places, they have different values at points where they are
not zero.

#local i=0;
#while(i < 6)
  #debug concat(str(Funcs[i](0.1,0.2,0.3),-1,-1),"\n")
  #declare i=i+1;
#end

There's a famous trigonometrical identity
        sin squared + cos squared = 1

If we apply that identity to this function
  function{ pow(SinTest(x,y,z),2) + pow(CosTest(x,y,z),2) - 1}
we can see that it always returns the value zero

We'd therefore expect that every point inside the container would be a
point on the surface, but the isosurface code isn't written in a way
that can take advantage of that. The tracer tries to find a point on the
ray where the function is greater than zero and another where the
function is less than zero and then produces successive approximations
to the point where the function changes sign. If the function is zero
everywhere, then that strategy gets confused. The speckles are being
produced by tiny rounding errors, the calculated values vary very
slightly from zero in one direction or the other causing the tracer to
think it has found a surface point.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: mwhidden
Subject: Re: Newbie isosurface question
Date: 13 Dec 2005 16:10:01
Message: <web.439f37dcdd86f32fc739b8ad0@news.povray.org>
Thank you sincerely for an excellent response (didactic in all its *best*
meanings.) Playing with the threshold parameter to the isosurface makes
your explanation easy to visualize. I'm glad I posted this in the newbie
forum, and now I see that thinking about isosurfaces is not just a trivial
step away from simple algebra.

Thanks again!

Mike Williams <nos### [at] econymdemoncouk> wrote:

> Although the function "x" and the function "sin(f_th(x,y,z))" are zero
> at the same places, they have different values at points where they are
> not zero.

[...]

> There's a famous trigonometrical identity
>         sin squared + cos squared = 1
>
> If we apply that identity to this function
>   function{ pow(SinTest(x,y,z),2) + pow(CosTest(x,y,z),2) - 1}
> we can see that it always returns the value zero


Post a reply to this message

From: mwhidden
Subject: Re: Newbie isosurface question
Date: 13 Dec 2005 16:30:01
Message: <web.439f3cf8dd86f32fc739b8ad0@news.povray.org>
"mwhidden" <nomail@nomail> wrote:
> Thank you sincerely for an excellent response (didactic in all its *best*
> meanings.) Playing with the threshold parameter to the isosurface makes
> your explanation easy to visualize. I'm glad I posted this in the newbie
> forum, and now I see that thinking about isosurfaces is not just a trivial
> step away from simple algebra.

For anyone interested, here is a modified version of the test file posted
above that shows how the isosurfaces for sin(f_th) and cos(f_th) do indeed
differ from x and z where their values are not zero (as pointed out by Mike
Williams).

I have combined the isosurfaces at various thresholds. The height of each
surface on the y-axis is directly proportional to the threshold used for
that surface, and the color changes for clarity (White corresponds to
threshold 0). You can see that the shape of the sin(f_th) and cos(f_th)
surfaces are very different from x and z when the threshold is non-zero.


----------------------

#include "colors.inc"
#include "functions.inc"

camera {
  location  <2.0, 10.5, -10.0>
  look_at   <6.0, 0.0,  0.0>
}

light_source { <-30, 30, -30>  color rgb 1 }
light_source { <-10, 30, -30>  color rgb 1 }

plane { y, 0
  pigment { color rgb <0.7,0.5,0.3> }
}

#declare XTest= function{x}

#declare SinTest= function{ sin(f_th(x,y,z))}

#declare ZTest= function {z}

#declare CosTest= function{ cos(f_th(x,y,z))}

#declare XZTest= function{pow(XTest(x,y,z),2) +
                          pow(ZTest(x,y,z),2) - 1}

#declare SinCosTest= function{ pow(SinTest(x,y,z),2) +
                               pow(CosTest(x,y,z),2) - 1}

#declare Funcs = array[6] {function{XTest(x,y,z)},
                           function{SinTest(x,y,z)},
                           function{ZTest(x,y,z)},
                           function{CosTest(x,y,z)},
                           function{XZTest(x,y,z)},
                           function{SinCosTest(x,y,z)}}

#local i=0;
#while(i < 6)
        #local j=1;
        #while(j >= -1)
                isosurface{
                        function {Funcs[i](x,y,z)}
                        contained_by {box {-1, <1, ((j+1)/1.8) + .2, 1>}}
                        open
                        threshold j
                        evaluate 0.6, 33, .7
                        texture{pigment{color vrotate(<1,1,1>, (j+2)*90)}}
                        translate i*3*x
                }
                difference{ box{-1,1} box {<-2,.1,-2>,2}
                            texture{pigment{color Blue}}
                            translate i*3*x}
        #local j=j-.2;
        #end
        #local i=i+1;
#end


Post a reply to this message

From: sully323
Subject: Re: Newbie isosurface question
Date: 8 Jan 2006 22:00:00
Message: <web.43c1d0b6dd86f32fad37533c0@news.povray.org>
"mwhidden" <nomail@nomail> wrote:
> "mwhidden" <nomail@nomail> wrote:
> > Thank you sincerely for an excellent response (didactic in all its *best*
> > meanings.) ....
>
> For anyone interested, here is a modified version of the test file posted
> above .....

  I am glad some of you consider this a "newbie" question! However, I have
been using POV for about 3 years now, and have never used an
isosurface....not one word of these posts made any sense to me
whatsoever....is there a tutorial for isosurfaces writen for those of us
that don't know math?


Post a reply to this message

From: Bob Hughes
Subject: Re: Newbie isosurface question
Date: 9 Jan 2006 01:23:54
Message: <43c2017a$1@news.povray.org>
"sully323" <lws### [at] netwaycom> wrote in message 
news:web.43c1d0b6dd86f32fad37533c0@news.povray.org...
>
>  I am glad some of you consider this a "newbie" question! However, I have
> been using POV for about 3 years now, and have never used an
> isosurface....not one word of these posts made any sense to me
> whatsoever....is there a tutorial for isosurfaces writen for those of us
> that don't know math?

Mike Williams' online isosurface tutorial sure makes it easy for me to 
understand. Might for you, too, then. Take a look at the "printable" link 
found at the bottom of that web page for a possibly easier read, if you are 
okay with scrolling-- or actual printed pages. Skips all that link-jump 
stuff.

http://www.econym.demon.co.uk/isotut/index.htm


Post a reply to this message

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