How does the centripetal Catmull–Rom spline work?
Asked Answered
C

3

18

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 mention how the points p0 and p3 affect the values between p1 and p2.

Another question I have is how would you create continuous splines? Would it be as easy as defining the points p1, p2 to be continuous with p4, p5 by making p4 = p2 (that is, assuming we have p0, p1, p2, p3, p4, p5, p6, ..., pN).

A more general question is how would one calculate tangents on Catmull-Rom splines? Would it have to involve taking two points on the spline (say at 0.01, 0.011) and getting the tangent based on Pythagoras, given the position coordinates those input values give?

Calchas answered 6/7, 2009 at 6:5 Comment(1)
Normal Catmull-Rom is also prone to loops and self-intersection which can be a problem. I strongly recommend using the centripetal parameterization shown here: #9490236Cosmogony
C
10

Take a look at equation 2 -- it describes how the control points affect the line. You can see points P0 and P3 go into the equation for plotting points along the curve from P1 to P2. You'll also see that the equation gives P1 when t == 0 and P2 when t == 1.

This example equation can be generalized. If you have points R0, R1, … RN then you can plot the points between RK and RK + 1 by using equation 2 with P0 = RK - 1, P1 = RK, P2 = RK + 1 and P3 = RK + 2.

You can't plot from R0 to R1 or from RN - 1 to RN unless you add extra control points to stand in for R - 1 and RN + 1. The general idea is that you can pick whatever points you want to add to the head and tail of a sequence to give yourself all the parameters to calculate the spline.

You can join two splines together by dropping one of the control points between them. Say you have R0, R1, …, RN and S0, S1, … SM they can be joined into R0, R1, …, RN - 1, S1, S2, … SM.

To compute the tangent at any point just take the derivative of equation 2.

Cart answered 6/7, 2009 at 7:5 Comment(0)
P
6

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.

Pantalets answered 6/7, 2009 at 6:51 Comment(1)
I'm sorry if I'm missing something, but could you point out where in the article it gives that formula? I see a different one at en.wikipedia.org/wiki/…. (I'm not all that good at math. I just wanted to know how you got the formula.)Thenceforth
F
1

This pdf may help you to understand in much better way. yes, to calculate the tangent, they includes the previous and next points based on the tension function.

It has derivation too.

https://www.cs.cmu.edu/~fp/courses/graphics/asst5/catmullRom.pdf

Fourhanded answered 15/6, 2022 at 8:3 Comment(2)
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.Vein
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewYazzie

© 2022 - 2024 — McMap. All rights reserved.