POV-Ray : Newsgroups : povray.binaries.images : A method creat uniform thick shell : Re: A method creat uniform thick shell Server Time
19 May 2024 09:34:29 EDT (-0400)
  Re: A method creat uniform thick shell  
From: Mike Horvath
Date: 29 Jul 2018 09:59:00
Message: <5b5dc824$1@news.povray.org>
On 7/28/2018 3:18 PM, Tor Olav Kristensen 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
> 
> 
> 

I don't understand the syntax.

#local GradientFn = fn_Gradient(input_function)

I did not know one could pass one function to another in this manner. I 
thought it was necessary to pass x, y, z instead. I.e.

#local GradientFn = fn_Gradient(x,y,z)


Mike


Post a reply to this message

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