The topic
Before starting the disussion of splines, I write about a curve between two points which corresponds to one spline segment.
A cubic curve - polynomial function of degree 3 - is determined by the four coefficients a, b, c, d with
f(x) = a + bx + cx2 + dx3
Constraints
With two points P0 = (x0,y0) und P1 = (x1,y1) given, the first two constraints are outright
a + bx0 + cx02 + dx03 = y0 | I |
a + bx1 + cx12 + dx13 = y1 | II |
For an equation system to be determined, two more constraints are required. For example, one of the following pairs:
- Slopes m0 and m1 at the two points:
b + 2cx0 + 3dx02 = m0, b + 2cx1 + 3dx12 = m1 - Slope at m0 and curvature u0 at point P0:
b + 2cx0 + 3dx02 = m0, 2c + 6dx0 = u0 - Curvatures u0 und u1 at the two points:
2c + 6dx0 = u0, 2c + 6dx1 = u1
Case 3: Curvatures at the two points
The two constraints for the curvatures may be put together with the first two constraints for y0 und y1 into an equation system:
y0 = a + bx0 + cx02 + dx03 | I |
y1 = a + bx1 + cx12 + dx13 | II |
u0 = 2c + 6dx0 | III |
u1 = 2c + 6dx1 | IV |
Determining the curvature change v is easiest done by considering the difference IV - III of the curvatures at the points:
u1 - u0 = 6d(x1 - x0) | IV - III |
d = (u1 - u0)/6(x1 - x0) |
Using either equation III or IV allows to determine c, then b by using II-I:
y1 - y0 = b(x1 - x0) + c(x12 - x02) + d(x13 - x03) | II-I |
b = ((y1 - y0) - c(x12 - x02) - d(x13 - x03))/(x1 - x0) |
finally a is determined using either equation I or II.
Graphs
The possibility above and two more to determine a curve of 3rd order at two points are shown in the graphic below:
Comments :