- Source: Akima spline
In applied mathematics, an Akima spline is a type of non-smoothing spline that gives good fits to curves where the second derivative is rapidly varying. The Akima spline was published by Hiroshi Akima in 1970 from Akima's pursuit of a cubic spline curve that would appear more natural and smooth, akin to an intuitively hand-drawn curve. The Akima spline has become the algorithm of choice for several computer graphics applications. Its advantage over the cubic spline curve is its stability with respect to outliers.
Method
Given a set of "knot" points
(
x
i
,
y
i
)
i
=
1
…
n
{\displaystyle (x_{i},y_{i})_{i=1\dots n}}
, where the
x
i
{\displaystyle x_{i}}
are strictly increasing, the Akima spline will go through each of the given points. At those points, its slope,
s
i
{\displaystyle s_{i}}
, is a function of the locations of the points
(
x
i
−
2
,
y
i
−
2
)
{\displaystyle (x_{i-2},y_{i-2})}
through
(
x
i
+
2
,
y
i
+
2
)
{\displaystyle (x_{i+2},y_{i+2})}
. Specifically, if we define
m
i
{\displaystyle m_{i}}
as the slope of the line segment from
(
x
i
,
y
i
)
{\displaystyle (x_{i},y_{i})}
to
(
x
i
+
1
,
y
i
+
1
)
{\displaystyle (x_{i+1},y_{i+1})}
, namely
m
i
=
y
i
+
1
−
y
i
x
i
+
1
−
x
i
,
{\displaystyle m_{i}={\frac {y_{i+1}-y_{i}}{x_{i+1}-x_{i}}}\,,}
then the spline slopes
s
i
{\displaystyle s_{i}}
are defined as the following
weighted average of
m
i
−
1
{\displaystyle m_{i-1}}
and
m
i
{\displaystyle m_{i}}
,
s
i
=
|
m
i
+
1
−
m
i
|
m
i
−
1
+
|
m
i
−
1
−
m
i
−
2
|
m
i
|
m
i
+
1
−
m
i
|
+
|
m
i
−
1
−
m
i
−
2
|
.
{\displaystyle s_{i}={\frac {|m_{i+1}-m_{i}|m_{i-1}+|m_{i-1}-m_{i-2}|m_{i}}{|m_{i+1}-m_{i}|+|m_{i-1}-m_{i-2}|}}\,.}
If the denominator equals zero, the slope is given as
s
i
=
m
i
−
1
+
m
i
2
.
{\displaystyle s_{i}={\frac {m_{i-1}+m_{i}}{2}}\,.}
The first two and the last two points need a special prescription, for example,
s
1
=
m
1
,
s
2
=
m
1
+
m
2
2
,
s
n
−
1
=
m
n
−
2
+
m
n
−
1
2
,
s
n
=
m
n
−
1
.
{\displaystyle s_{1}=m_{1}\,,s_{2}={\frac {m_{1}+m_{2}}{2}}\,,s_{n-1}={\frac {m_{n-2}+m_{n-1}}{2}}\,,s_{n}=m_{n-1}\,.}
The spline is then defined as the piecewise cubic function whose value between
x
i
{\displaystyle x_{i}}
and
x
i
+
1
{\displaystyle x_{i+1}}
is the unique cubic polynomial
P
i
(
x
)
{\displaystyle P_{i}(x)}
,
P
i
(
x
)
=
a
i
+
b
i
(
x
−
x
i
)
+
c
i
(
x
−
x
i
)
2
+
d
i
(
x
−
x
i
)
3
,
{\displaystyle P_{i}(x)=a_{i}+b_{i}(x-x_{i})+c_{i}(x-x_{i})^{2}+d_{i}(x-x_{i})^{3}\,,}
where the coefficients of the polynomial are chosen such that the four conditions of continuity of the spline together with its first derivative are satisfied,
P
(
x
i
)
=
y
i
,
P
(
x
i
+
1
)
=
y
i
+
1
,
P
′
(
x
i
)
=
s
i
,
P
′
(
x
i
+
1
)
=
s
i
+
1
.
{\displaystyle P(x_{i})=y_{i}\,,P(x_{i+1})=y_{i+1}\,,P'(x_{i})=s_{i}\,,P'(x_{i+1})=s_{i+1}\,.}
which gives
a
i
=
y
i
,
{\displaystyle a_{i}=y_{i}\,,}
b
i
=
s
i
,
{\displaystyle b_{i}=s_{i}\,,}
c
i
=
3
m
i
−
2
s
i
−
s
i
+
1
x
i
+
1
−
x
i
,
{\displaystyle c_{i}={\frac {3m_{i}-2s_{i}-s_{i+1}}{x_{i+1}-x_{i}}}\,,}
d
i
=
s
i
+
s
i
+
1
−
2
m
i
(
x
i
+
1
−
x
i
)
2
.
{\displaystyle d_{i}={\frac {s_{i}+s_{i+1}-2m_{i}}{(x_{i+1}-x_{i})^{2}}}\,.}
Due to these conditions the Akima spline is a C1 differentiable function, that is, the function itself is continuous and the first derivative is also continuous. However, in general, the second derivative is not necessarily continuous.
An advantage of the Akima spline is due to the fact that it uses only values from neighboring knot points in the construction of the coefficients of the interpolation polynomial between any two knot points. This means that there is no large system of equations to solve and the Akima spline avoids unphysical wiggles in regions where the second derivative in the underlying curve is rapidly changing. A possible disadvantage of the Akima spline is that it has a discontinuous second derivative.
References
External links
Online demo of Akima spline interpolation in TypeScript