POV-Ray : Newsgroups : povray.binaries.images : A method creat uniform thick shell Server Time
24 Apr 2024 00:31:27 EDT (-0400)
  A method creat uniform thick shell (Message 11 to 20 of 45)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Christian Froeschlin
Subject: Re: A method creat uniform thick shell
Date: 26 Oct 2013 12:55:04
Message: <526bf3e8$1@news.povray.org>
Very good technique!

The presentation of it was maybe a bit hard to follow.

To summarize:

1. If you have geometry described by a function (as used by
an isosurface object), you can can render its boundary using
a constant thickness (as opposed to the entire solid object).

2. The technique is to difference two isosurface objects for
the same function using a slightly different threshold.

3. In order to achieve constant thickness the function needs to
be normalized by dividing through the length of its gradient.


In your examples, you used simple functions for which the
derivative could be calculated analytically. Maybe this could
also be done by a general macro that uses a gradient of

sqrt(((f(x+e,y,z)-f(x,y,z))/e)^2,
      ((f(x,y+e,z)-f(x,y,z))/e)^2,
      ((f(x,y,z+e)-f(x,y,z))/e)^2)

for some small value of e?


Post a reply to this message

From: Christian Froeschlin
Subject: Re: A method creat uniform thick shell
Date: 26 Oct 2013 12:57:09
Message: <526bf465$1@news.povray.org>
Christian Froeschlin wrote:

 > sqrt(((f(x+e,y,z)-f(x,y,z))/e)^2,
 >      ((f(x,y+e,z)-f(x,y,z))/e)^2,
 >      ((f(x,y,z+e)-f(x,y,z))/e)^2)

Oops that should have been

sqrt(((f(x+e,y,z)-f(x,y,z))/e)^2 +
      ((f(x,y+e,z)-f(x,y,z))/e)^2 +
      ((f(x,y,z+e)-f(x,y,z))/e)^2)


Post a reply to this message

From: And
Subject: Re: A method creat uniform thick shell
Date: 27 Oct 2013 06:25:00
Message: <web.526ce92ddce0719a84f168e50@news.povray.org>
Christian Froeschlin <chr### [at] chrfrde> wrote:
> Very good technique!
>
> The presentation of it was maybe a bit hard to follow.
>
> To summarize:
>
> 1. If you have geometry described by a function (as used by
> an isosurface object), you can can render its boundary using
> a constant thickness (as opposed to the entire solid object).
>
> 2. The technique is to difference two isosurface objects for
> the same function using a slightly different threshold.
>
> 3. In order to achieve constant thickness the function needs to
> be normalized by dividing through the length of its gradient.
>
>
> In your examples, you used simple functions for which the
> derivative could be calculated analytically. Maybe this could
> also be done by a general macro that uses a gradient of
>
> sqrt(((f(x+e,y,z)-f(x,y,z))/e)^2+
>       ((f(x,y+e,z)-f(x,y,z))/e)^2+
>       ((f(x,y,z+e)-f(x,y,z))/e)^2)
>
> for some small value of e?

Thank you.
Your summary is so good!!

And I've tried with an approximate derivative, it works.
#declare f_sin=function(var1,var2,k){
var2-sin(k*var1)
}

#declare f_sin_normalized=function(var1,var2,k,e){
f_sin(var1,var2,k)
/sqrt(
pow((f_sin(var1+e,var2,k)-f_sin(var1,var2,k))/e,2)
+pow((f_sin(var1,var2+e,k)-f_sin(var1,var2,k))/e,2)
)
}


I invoke function in isosurface with e=0.001
it took twice time to render, but it's OK because the image is identical.
I may write it by a macro then try some other function.


Post a reply to this message

From: And
Subject: Re: A method creat uniform thick shell
Date: 28 Oct 2013 00:55:00
Message: <web.526dedcadce0719a84f168e50@news.povray.org>
"Cousin Ricky" <rickysttATyahooDOTcom> wrote:
> Nice!

ya!


Post a reply to this message

From: And
Subject: Re: A method creat uniform thick shell
Date: 30 Oct 2013 12:35:01
Message: <web.52713448dce0719ad7d2abf60@news.povray.org>
I have written a macro which uses above technique to make an isosurface thin
shell. I post it below. But I found that it is only for a small thickness or it
don't have a constant thickness result. Furthermore, for many functions its
result is not expect.

So, don't take too much expect with it.

//-------------------macro-----------------------------

#macro Shape_ThinShellOf3DFunction(input_function, _min_extent, _max_extent,
_thickness, _max_gradient)
#local CSG_OVERLAP=0.001;
#local h=0.00001;
#local normalized_function =
function(var1,var2,var3)
{
input_function(var1,var2,var3)
/sqrt(
pow((input_function(var1+h,var2,var3)-input_function(var1,var2,var3))/h,2)
+pow((input_function(var1,var2+h,var3)-input_function(var1,var2,var3))/h,2)
+pow((input_function(var1,var2,var3+h)-input_function(var1,var2,var3))/h,2)
)
}
difference{
isosurface{
function{normalized_function(x,y,z)-_thickness/2}
max_gradient _max_gradient
contained_by{box{_min_extent,_max_extent}}
all_intersections
}
isosurface{
function{normalized_function(x,y,z)+_thickness/2}
max_gradient _max_gradient
contained_by{box{_min_extent-<CSG_OVERLAP,CSG_OVERLAP,CSG_OVERLAP>,_max_extent+<CSG_OVERLAP,CSG_OVERLAP,CSG_OVERLAP>}}
all_intersections
}
}
#end





//---------------------Here is a good look example------

#declare f_noise3d = function { internal(76) }
#declare f_test=
function(x,y,z){
x*x+y*y+z*z-1- 0.5*f_noise3d(x/0.3,y/0.3,z/0.3)
}

difference{
Shape_ThinShellOf3DFunction(f_test, <-1.3,-1.3,0>, <1.3,1.3,1.3>, 0.04, 10)
box{<-1.5,-1.5,-0.1>,<1.5,0,1.5>}
texture{
    pigment{rgb<1,1,1>}
    finish{
        ambient 0.1
        diffuse 0.6
    }
}
}

//----------------------------------------------------------


Post a reply to this message

From: posfan12
Subject: Re: A method creat uniform thick shell
Date: 21 Jul 2018 02:35:00
Message: <web.5b52d387dce0719a34baa4ef0@news.povray.org>
"And" <49341109@ntnu.edu.tw> wrote:
> Hi,
> I have a method using isosurface render spheroid shell below.
>
> use this two function
>
> #declare f_spheroid=function(var1,var2,var3, a,b){
> var1*var1/a/a+var2*var2/a/a+var3*var3/b/b-1
> }
>
> #declare f_spheroid_normalized=function(var1,var2,var3, a,b){
> f_spheroid(var1,var2,var3, a,b)
> /sqrt(4*(var1*var1+var2*var2)/pow(a,4)+4*var3*var3/pow(b,4))
> }
>
>
> //than difference these two isosurfaces
> difference{
> isosurface{
> function{f_spheroid(x,y,z,1,3)}
> }
> isosurface{
> function{f_spheroid_normalized(x,y,z,1,3)+thickness}
> }
> }

How do I add a "c" parameter to the ellipsoid, in addition to "a" and "b"? I can
see how to add "c" to "f_spheroid" function. But I don't understand what's going
on in "f_spheroid_normalized". Thanks.


Mike


Post a reply to this message

From: posfan12
Subject: Re: A method creat uniform thick shell
Date: 21 Jul 2018 02:40:00
Message: <web.5b52d476dce0719a34baa4ef0@news.povray.org>
"And" <49341109@ntnu.edu.tw> wrote:
> Hi,
> I have a method using isosurface render spheroid shell below.
>
> use this two function
>
> #declare f_spheroid=function(var1,var2,var3, a,b){
> var1*var1/a/a+var2*var2/a/a+var3*var3/b/b-1
> }
>
> #declare f_spheroid_normalized=function(var1,var2,var3, a,b){
> f_spheroid(var1,var2,var3, a,b)
> /sqrt(4*(var1*var1+var2*var2)/pow(a,4)+4*var3*var3/pow(b,4))
> }
>
>
> //than difference these two isosurfaces
> difference{
> isosurface{
> function{f_spheroid(x,y,z,1,3)}
> }
> isosurface{
> function{f_spheroid_normalized(x,y,z,1,3)+thickness}
> }
> }


(This may be a double post. Not sure. Sorry!)

The above function as the "a" and "b" parameters for the ellipsoid. How do I add
the "c" parameter for the third axis? I can see where it goes in "f_spheroid",
but I don't understand "f_spheroid_normalized". Thanks.


Mike


Post a reply to this message

From: Mike Horvath
Subject: Re: A method creat uniform thick shell
Date: 21 Jul 2018 02:51:24
Message: <5b52d7ec$1@news.povray.org>
On 7/21/2018 2:36 AM, posfan12 wrote:
> "And" <49341109@ntnu.edu.tw> wrote:
>> Hi,
>> I have a method using isosurface render spheroid shell below.
>>
>> use this two function
>>
>> #declare f_spheroid=function(var1,var2,var3, a,b){
>> var1*var1/a/a+var2*var2/a/a+var3*var3/b/b-1
>> }
>>
>> #declare f_spheroid_normalized=function(var1,var2,var3, a,b){
>> f_spheroid(var1,var2,var3, a,b)
>> /sqrt(4*(var1*var1+var2*var2)/pow(a,4)+4*var3*var3/pow(b,4))
>> }
>>
>>
>> //than difference these two isosurfaces
>> difference{
>> isosurface{
>> function{f_spheroid(x,y,z,1,3)}
>> }
>> isosurface{
>> function{f_spheroid_normalized(x,y,z,1,3)+thickness}
>> }
>> }
> 
> 
> (This may be a double post. Not sure. Sorry!)
> 
> The above function as the "a" and "b" parameters for the ellipsoid. How do I add
> the "c" parameter for the third axis? I can see where it goes in "f_spheroid",
> but I don't understand "f_spheroid_normalized". Thanks.
> 
> 
> Mike
> 

Never mind. I figured it out.

Mike


Post a reply to this message

From: And
Subject: Re: A method creat uniform thick shell
Date: 22 Jul 2018 06:20:01
Message: <web.5b545a3ddce0719ae897ce530@news.povray.org>
Mike Horvath <mik### [at] gmailcom> wrote:
> On 7/21/2018 2:36 AM, posfan12 wrote:
> > "And" <49341109@ntnu.edu.tw> wrote:
> >> Hi,
> >> I have a method using isosurface render spheroid shell below.
> >>
> >> use this two function
> >>
> >> #declare f_spheroid=function(var1,var2,var3, a,b){
> >> var1*var1/a/a+var2*var2/a/a+var3*var3/b/b-1
> >> }
> >>
> >> #declare f_spheroid_normalized=function(var1,var2,var3, a,b){
> >> f_spheroid(var1,var2,var3, a,b)
> >> /sqrt(4*(var1*var1+var2*var2)/pow(a,4)+4*var3*var3/pow(b,4))
> >> }
> >>
> >>
> >> //than difference these two isosurfaces
> >> difference{
> >> isosurface{
> >> function{f_spheroid(x,y,z,1,3)}
> >> }
> >> isosurface{
> >> function{f_spheroid_normalized(x,y,z,1,3)+thickness}
> >> }
> >> }
> >
> >
> > (This may be a double post. Not sure. Sorry!)
> >
> > The above function as the "a" and "b" parameters for the ellipsoid. How do I add
> > the "c" parameter for the third axis? I can see where it goes in "f_spheroid",
> > but I don't understand "f_spheroid_normalized". Thanks.
> >
> >
> > Mike
> >
>
> Never mind. I figured it out.
>
> Mike

Is it ok?


Post a reply to this message

From: Mike Horvath
Subject: Re: A method creat uniform thick shell
Date: 22 Jul 2018 10:43:49
Message: <5b549825$1@news.povray.org>
On 7/22/2018 6:19 AM, And wrote:
> Mike Horvath <mik### [at] gmailcom> wrote:
>>
>> Never mind. I figured it out.
>>
>> Mike
> 
> Is it ok?
> 

Yes, it works well!

The routine would be very helpful in this object collection:

http://lib.povray.org/searchcollection/index2.php?objectName=ShapeGrid&version=1.11&contributorTag=SharkD

Would it be okay if I added it there? The license for the collection is 
CC-LGPL.

Thanks!

Mike


Post a reply to this message

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

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