POV-Ray : Newsgroups : povray.pov4.discussion.general : Suggest v4.0 f_kappa_2d() function. (yuqk R19 v0.6.13.0) : Re: Suggest v4.0 f_kappa_2d() function. (yuqk R19 v0.6.13.0) Server Time
23 Feb 2025 21:22:37 EST (-0500)
  Re: Suggest v4.0 f_kappa_2d() function. (yuqk R19 v0.6.13.0)  
From: William F Pokorny
Date: 23 Feb 2025 16:00:48
Message: <67bb8c80$1@news.povray.org>
On 2/23/25 09:07, Bald Eagle wrote:
> William F Pokorny <ano### [at] anonymousorg> wrote:
> 
>> This a general helper function / technique to match any two curves at
>> their endpoints given you have the means to calculate the first and
>> second derivatives for both curves being glued together at (t).
> 
> Are f' and f" arguments to the function?

Could be, but see below.

> 
>> The function will calculate and return 'k(t)' or the 'radius of
>> curvature' (1.0/k(t)).
>>
>> Attaching images showing on the left k(t), and on the right the 'radius
>> of curvature' at t, as the length of the normal vectors for a
>> f_bezier_2d_cubic() curve.
> 
...
> 
> Do you plug f_bezier_2d_cubic() into your function and it calculates the
> derivatives?  Can you plug in, say, Perlin Noise, and have that work?
> 

Sort of.

No. The capability isn't that general - and limited to 2D (*).

With the f_bezier_2d_* functions and, for example, f_catenary() from a 
few releases back, the function which generates the curve has too 
calculation modes inbuilt for the first and second derivatives - and 
sometimes the third as well.

So the typical set up would be something like:

//...
#declare FnBez_2d = function (ro_t,ro_mode) {
     f_bezier_2d_cubic(
           f_enc2x_f32(-1.0,0),
           f_enc2x_f32(-1/2,0.5),
           f_enc2x_f32(+1/2,-0.5),
           f_enc2x_f32(1.0,0),
           ro_t,ro_mode
     )
}
#declare U02 = union {
     #for (I,0,SphCnt,4)
...
         #declare D1 = FnBez_2d(I/SphCnt,3); // Calc raw 1st derivative
         #declare D2 = FnBez_2d(I/SphCnt,4); // Calc raw 2nd derivative
         #declare Kappa = f_kappa_2d(D1,D2,0); // Pass the values
...
     #end
     texture { pigment { Frostbite } finish {emission 1.0} }
}
//...

Where you have a univariate polynomial for the curve, it's not too bad 
to calculate the derivative polynomials as Alain pointed out.

Bill P.

(*) Lying some as by measuring local deltas we could probably come up 
with D1 & D2 values which would be in the ballpark to some sampling 
accuracy.


Post a reply to this message

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