How does the centripetal Catmull–Rom spline work?

后端 未结 2 1664
时光说笑
时光说笑 2020-12-07 21:45

From this site, which seems to have the most detailed information about Catmull-Rom splines, it seems that four points are needed to create the spline. However, it does not

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 22:26

    The Wikipedia article goes into a little bit more depth. The general form of the spline takes as input 2 control points with associated tangent vectors. Additional spline segments can then be added provided that the tangent vectors at the common control points are equal, which preserves the C1 continuity.

    In the specific Catmull-Rom form, the tangent vector at intermediate points is determined by the locations of neighboring control points. Thus, to create a C1 continuous spline through multiple points, it is sufficient to supply the set of control points and the tangent vectors at the first and last control point. I think the standard behavior is to use P1 - P0 for the tangent vector at P0 and PN - PN-1 at PN.

    According to the Wikipedia article, to calculate the tangent at control point Pn, you use this equation:

    T(n) = (P(n - 1) + P(n + 1)) / 2
    

    This also answers your first question. For a set of 4 control points, P1, P2, P3, P4, interpolating values between P2 and P3 requires information form all 4 control points. P2 and P3 themselves define the endpoints through which the interpolating segment must pass. P1 and P3 determine the tangent vector the interpolating segment will have at point P2. P4 and P2 determine the tangent vector the segment will have at point P3. The tangent vectors at control points P2 and P3 influence the shape of the interpolating segment between them.

提交回复
热议问题