splinebox.spline_curves.HermiteSpline.

translate#

HermiteSpline.translate(vector)#

Translates the spline by a vector.

Parameters:
vectornumpy.ndarray

Displacement vector added to the coefficients.

Examples

>>> import splinebox
>>> import numpy as np
>>> import matplotlib.pyplot as plt

We start by creating a spline

>>> spline = splinebox.Spline(M=4, basis_function=splinebox.B3(), closed=True)
>>> spline.control_points = np.array([[3, 0], [1, 1], [-1, 0], [-1, -1]])

Let’s plot the spline:

>>> t = np.linspace(0, spline.M, 1000)
>>> vals = spline(t)
>>> plt.plot(vals[:, 0], vals[:, 1], label="orig")

Next, we translate the spline and plot it again:

>>> spline.translate(np.array([1, 1]))
>>> vals = spline(t)
>>> plt.plot(vals[:, 0], vals[:, 1], linestyle="--", label="transl")
>>> plt.legend()
>>> plt.show()
../../_images/splinebox-spline_curves-HermiteSpline-translate-1.png