POV-Ray : Newsgroups : povray.advanced-users : Length of spline... : Re: Length of spline... Server Time
30 Jul 2024 08:19:49 EDT (-0400)
  Re: Length of spline...  
From: Chris Colefax
Date: 27 Oct 2000 20:52:02
Message: <39fa2332@news.povray.org>
Fabian BRAU <Fab### [at] umhacbe> wrote:
> Could you give me the form of the function (this mathematical form)?

Here is the way I derived the basic cubic spline function, the constraints
being the two end-points and two end-tangents of the curve segment (known as
a Hermite curve).  The various cubic interpolating splines (e.g.
Catmull-Rom, cardinal, Bezier, Kochanek-Bartels/TCB) can be easily converted
to this simple definition, where p(t) returns the posiition (p) at the time
(t, with 0 <= t <= 1).

Let p(t) be cubic polynomial => p(t) = a*t^3 + b*t^2 + c*t + d

Let end-points be P0 and P1 => p(0) = P0, p(1) = P1
Let end-tangents be T0 and T1 => p'(0) = T0, p'(1) = T1
 => P0 = d
    P1 = a + b + c + d
    T0 = c
    T1 = 3*a + 2*b + c

Solve for a, b, c, d:
      a = 2*(P0 - P1) + T0 + T1
      b = 3*(P1 - P0) - 2*T0 - T1
      c = T0
      d = P0

Subsitute a, b, c, d into p(t), giving general Hermite curve:
   => p(t) = (2*(P0 - P1) + T0 + T1)*t^3  +  (3*(P1 - P0) - 2*T0 - T1)*t^2
+  T0*t  +  P0
           = T0 * (t^3 - 2*t^2 + t)  +  P0*(2*t^3 - 3*t^2 + 1)  +
 P1*(3*t^2 - 2*t^3)  +  T1*(t^3 - t^2)


Post a reply to this message

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