 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christian Froeschlin <chr### [at] chrfr de> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Cousin Ricky" <rickysttATyahooDOTcom> wrote:
> Nice!
ya!
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Mike Horvath <mik### [at] gmail com> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 7/22/2018 6:19 AM, And wrote:
> Mike Horvath <mik### [at] gmail com> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |