|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"And" <49341109@ntnu.edu.tw> wrote:
> This is another function and picture:
> #declare CSG_OVERLAP=0.000001;
> #declare f_quartic=function(var1,var2){
> pow(var1,4)+2*var1*var1*var2*var2+var1*var1-1
> }
>
> #declare f_quartic_normalized=function(var1,var2){
> f_quartic(var1,var2)
>
/sqrt(16*pow(var1,6)+(48*var2*var2+16)*pow(var1,4)+(16*pow(var2,4)+16*var2*var2+4)*var1*var1)
> }
>
> difference{
> isosurface{
> function{f_quartic(y,x)}
> max_gradient 10
> contained_by{box{<-3,0,-1><3,1.3,3>}}
> all_intersections
> }
> isosurface{
> function{f_quartic_normalized(y,x)+0.04}
> max_gradient 10
> contained_by{box{<-3,0-CSG_OVERLAP,-1-CSG_OVERLAP><3,1.3,3+CSG_OVERLAP>}}
> all_intersections
> }
> }
Ooops! I don't know why but with pov 3.7 it works! Not with 3.6!
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Fractracer" <lg.### [at] gmailcom> wrote:
>
> I've tried to use yours functions but I have an error message:
> Parse Error: Floating-point exception detected in function
> 'f_quartic_normalized'. Your function either attempted a division by zero, used
> a function outside its domain or called an internal function with invalid
> parameters.
> I don't know what happens...
Hum...
I just tried and this have parse error in pov-ray 3.6 truly.
Or you can use below function instead:
#declare f_quartic_normalized=function(var1,var2){
select(
abs(var1)-0.01,
-1,
f_quartic(var1,var2)
/sqrt(16*pow(var1,6)+(48*var2*var2+16)*pow(var1,4)+(16*pow(var2,4)+16*var2*var2+4)*var1*var1)
)
}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I explain this method. The basic concept is just that specifying different
threshold values to a function will produce different but similar isosurfaces.
For instance, in the right picture, upper surface of the shell is
y-sin(2.5*x)= 0.08 , lower surface is
y-sin(2.5*x)=-0.08
Use csg difference in pov-ray between these two isosurface objects can produce a
shell.
//---------------------code----------------------------
#declare f_sin=function(var1,var2,k){
var2-sin(k*var1)
}
#declare CSG_OVERLAP=0.000001;
difference{
isosurface{
function{f_sin(x,z,2.5)-0.08}
max_gradient 2
contained_by{box{<-5,-1,-1.5><5,2,1.5>}}
all_intersections
}
isosurface{
function{f_sin(x,z,2.5)+0.08}
max_gradient 2
contained_by{box{<-5,-1-CSG_OVERLAP,-1.5-CSG_OVERLAP><5,2+CSG_OVERLAP,1.5>}}
all_intersections
}
}
//-----------------------end of code-----------------------
But the shell's thickness is not a canstant. I found a method modifying the
function to let it have uniform thickness at least in a small range.
Post a reply to this message
Attachments:
Download 'sin.jpg' (130 KB)
Preview of image 'sin.jpg'
|
|
| |
| |
|
|
|
|
| |
| |
|
|
The method had been represented the other day. The modified function for sin
function is
(y-sin(2.5*x))/sqrt(2.5^2*cos(2.5*x)^2+1)= 0.08 ,
(y-sin(2.5*x))/sqrt(2.5^2*cos(2.5*x)^2+1)=-0.08
^^^^^^
0.08 represent the thickness/2
Then use pov-ray's csg difference:
//---------------------------code---------------------------
#declare f_sin=function(var1,var2,k){
var2-sin(k*var1)
}
#declare f_sin_normalized=function(var1,var2,k){
f_sin(var1,var2,k)
/sqrt(k*k*pow(cos(k*var1),2)+1)
}
#declare CSG_OVERLAP=0.000001;
difference{
isosurface{
function{f_sin_normalized(x,z,2.5)-0.08}
max_gradient 2
contained_by{box{<-5,-1,-1.5><5,2,1.5>}}
all_intersections
}
isosurface{
function{f_sin_normalized(x,z,2.5)+0.08}
max_gradient 2
contained_by{box{<-5,-1-CSG_OVERLAP,-1.5-CSG_OVERLAP><5,2+CSG_OVERLAP,1.5>}}
all_intersections
}
}
//--------------------------end of code--------------------------
Drew the picture!!
Post a reply to this message
Attachments:
Download 'sin_normalized.jpg' (117 KB)
Preview of image 'sin_normalized.jpg'
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Nice!
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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] 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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"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
|
|
| |
| |
|
|
|
|
| |
|
|