|
|
"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
Post a reply to this message
|
|