POV-Ray : Newsgroups : povray.advanced-users : Curve calculation : Re: Curve calculation Server Time
30 Jul 2024 14:16:22 EDT (-0400)
  Re: Curve calculation  
From: Jerry Anning
Date: 23 May 1999 19:47:57
Message: <374884f0.11271740@news.povray.org>
On Sun, 23 May 1999 20:27:33 +0300, Lewis <nle### [at] netvisionnetil>
wrote:

>Sorry, I just realized this doesn't really help me.
>If you can explain how to calculate a curve, it would help. I
>specifically need one that goes through the certain specified points, so
>just choose any and if you don't mind, tell me how its done,
>mathematically.

Here is an excerpt from a letter I wrote once, modified to use the Tau
spline that I recommend.  There are more efficient ways, but this is
good enough.  If you need more, let me know.

To generate your starting points, you need to explicitly do the
Tau spline calculations.  First
set up an array containing the control points for your object. 
Then set up an array as the Tau basis matrix.  This array is as
follows:

#declare Basis = array[4][4]
  {
    { (Bias - 1) * Tens, 2 - Bias * Tens, (1 - Bias) * Tens - 2, Bias
* Tens },
    { 2 * (1 - Bias) * Tens, (3 * Bias - 1) * Tens - 3, 3 - Tens,
-Bias * Tens },
    { (Bias - 1) * Tens, (1 - 2 * Bias) * Tens, Bias * Tens, 0 },
    { 0, 1, 0, 0 }
  }

(You can use any uniform cubic spline basis you like with minimal
changes to the code, but the shape you get will vary.)  Next, set up
macros to carry out the spline calculation.  I use a simple macro to
do
the basic multiplications with Horner's Rule:
(Param *(Param * (Param * Basis[0][Row] + Basis[1][Row]) +
Basis[2][Row]) + Basis[3][Row]) * Point

Then I set up another simple macro to use the Horner macro for cubic
interpolation:
Horner(T, 0, Points[This - 1]) + Horner(T, 1, Points[This]) +
Horner(T,
2, Points[This + 1]) + Horner[T, 3, Points[This + 2])

Then I would use a loop to generate the actual points along the 
spline from the control points with pseudocode something like this:

Increment = .2 (or more or less, depending on the detail of the
object)
Index = 0
This = 1
while (This < sizeof[Points])
T = 0
while (T < 1)
Actualpoint[Index] = Cubic_interpolate(T, This)
T = T + Incr
Index =Index + 1
endwhile
This = This + 1
endwhile

Jerry Anning
clem "at" dhol "dot" com


Post a reply to this message

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