POV-Ray : Newsgroups : povray.binaries.images : A method creat uniform thick shell : Re: A method creat uniform thick shell Server Time
19 May 2024 12:10:43 EDT (-0400)
  Re: A method creat uniform thick shell  
From: Tor Olav Kristensen
Date: 28 Jul 2018 15:20:00
Message: <web.5b5cc18bdce0719a9cbeb2fe0@news.povray.org>
"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

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