This page was generated from
doc/euclidean/natural-properties.ipynb.
Interactive online version:
.
Properties of Natural Splines§
The most important property of natural splines is that they are \(C^2\) continuous, which means that the second derivatives match at section borders.
[1]:
import splines
[2]:
vertices = [
(0, 0),
(1, 0),
(2, 1),
(3, 1),
]
We use the class splines.Natural …
[3]:
s = splines.Natural(vertices)
… and a plotting function from helper.py:
[4]:
from helper import plot_spline_2d
[5]:
plot_spline_2d(s)
[6]:
def plot_natural(*args, **kwargs):
plot_spline_2d(splines.Natural(*args, **kwargs), chords=False)
A downside of natural splines is that they don’t provide local control. Changing only a single control point potentially influences the whole curve.
[7]:
plot_natural([
(0, 0),
(0.5, 0),
(2, -1),
(3, 2),
(1, 3),
(-2, 2),
])
plot_natural([
(0, 0),
(0.5, 0),
(2, -0.5),
(3, 2),
(1, 3),
(-2, 2),
])
By default, natural end conditions are used, but alternatively, the end tangents can be clamped to given values.
[8]:
plot_natural(vertices, endconditions='natural')
plot_natural(vertices, endconditions=[[0, 0], 'natural'])
plot_natural(vertices, endconditions=[[1, -1], 'natural'])
plot_natural(vertices, endconditions=[[2, -2], 'natural'])
[9]:
plot_natural(vertices, endconditions='closed')
[10]:
plot_natural(vertices, endconditions='closed', alpha=0.5)