2
$\begingroup$

I have created cubic curve using CatmullRom Spline or Akima spline. From those, I obtain $a, b, c, d$ parameters.

To get point on the curve, I do this

$f(t) = a + bt + ct^2 + dt^3$

How to get tangent at $f(t)$? By just simply doing

$ f´(t) = b + 2ct + 3dt^3$

or is this wrong and I have to calculate new $a, b, c, d$ as well?

EDIT:

For example, Catmull-Rom is calculated

SplineSegment[] C = new SplineSegment[n];
for (all control points)
{
    C[i].a = 0.5f * (                 2 * cp[i]);
    C[i].b = 0.5f * (   - cp[i - 1]             +     cp[i + 1]);
    C[i].c = 0.5f * ( 2 * cp[i - 1] - 5 * cp[i] + 4 * cp[i + 1] - cp[i + 2]);
    C[i].d = 0.5f * (   - cp[i - 1] + 3 * cp[i] - 3 * cp[i + 1] + cp[i + 2]);           
}

Natural cubic spline:

SplineSegment[] C = new SplineSegment[n];
for (all control points)
{
    C[i].a = cp[i];
    C[i].b = D[i];
    C[i].c = 3 * (cp[i + 1] - cp[i]) - 2 * D[i] - D[i + 1];
    C[i].d = 2 * (cp[i] - cp[i + 1]) + D[i] + D[i + 1];
}

//D is calculated from Cubic spline matrix
$\endgroup$

1 Answer 1

2
$\begingroup$

You are right. The tangent of the curve f(t) is obtained by taking first derivative of f(t). But your equation has a minor mistake (a typo I believe). It should be $f'(t)=b+2ct+3dt^2$.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .