 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Thanks!!
Could you bundle this into an INC file please? Then I can link to the
newsgroup message URL from within my scene.
Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmail com> wrote:
> Note that pow(x, 2) may be faster to evaluate than x*x.
I thought that the opposite was true, that x*x would be less 'computationally
expensive' than invoking the pow function. I honestly don't know for sure; but
I recall something being said about this in an older thread.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
I have messed around with this, and I would not call the thickness
exactly uniform. Is it impossible to do?
Mike
Post a reply to this message
Attachments:
Download 'offset_surface_save_06.png' (60 KB)
Preview of image 'offset_surface_save_06.png'

|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmail com> wrote:
> "And" <49341109@ntnu.edu.tw> wrote:
> >...
> > #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)
> > )
> > }
> >...
>
> And, there is a macro in math.inc that can create the gradient function for your
> denominator: fn_Gradient()
>
> Here's how you can use it:
>
> #include "math.inc"
>
> SetGradientAccuracy(h)
> #local GradientFn = fn_Gradient(input_function)
> #local normalized_function =
> function { input_function(x, y, z)/GradientFn(x, y, z) }
>
>
> I suspect that this will be a little faster, since fn_Gradient() uses f_r()
> instead of sqrt() and pow() and since the division by h (or 2*h in fn_Gradient)
> is moved outside.
>
> Here's the relevant documentation pages:
> http://www.povray.org/documentation/view/3.6.1/460/
> http://www.povray.org/documentation/3.7.0/r3_4.html#r3_4_9_1_12_3
>
> --
> Tor Olav
> http://subcube.com
Oh, okay.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Mike Horvath <mik### [at] gmail com> wrote:
> On 7/29/2018 3:57 PM, Tor Olav Kristensen wrote:
> > fn_Gradient() is not a function. It is a macro within math.inc. When you pass a
> > function to this macro it will create and return a new function that estimates
> > the magnitude of the gradient of the function that you passed to it.
> >
> > The function that you pass to this macro must take 3 arguments; usually x, y and
> > z (but their names doesn't really matter). And the function that it returns
> > takes 3 arguments.
> >
> > --
> > Tor Olav
> > http://subcube.com
> >
>
> I tried this code:
>
> #declare f_test = function(var1,var2,var3)
> {pow(var1,2)+pow(var2,2)+pow(var3,2)-1-0.5*f_noise3d(var1*3,var2*3,var3*3)}
> #declare f_normalized = function(var1,var2,var3,varA,varB,varC)
>
{f_test(var1,var2,var3)/sqrt(4*pow(var1,2)/pow(varA,4)+4*pow(var2,2)/pow(varB,4)+4*pow(var3,2)/pow(varC,4))}
>
> and this code:
>
> SetGradientAccuracy(0.0001)
> #declare f_test= function {x*x+y*y+z*z-1-0.5*f_noise3d(x*3,y*3,z*3)}
> #declare f_input = function {f_test(x,y,z)}
> #declare GradientFn = fn_Gradient(f_input)
> #declare f_normalized = function {f_input(x,y,z)/GradientFn(x,y,z)}
>
> And the latter was much slower. Is there a way to speed it up?
>
>
> Mike
No no
If you would like to create a constant thickness shell. You must use the second
code.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |