splinebox.spline_curves.HermiteSpline.
rotate#
- HermiteSpline.rotate(rotation_matrix, centred=True)#
Rotate the spline with the provided rotation matrix.
- Parameters:
- rotation_matrixnumpy.ndarray
The rotation matrix applied to the spline.
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 rotate the spline and plot it again:
>>> theta = np.deg2rad(45) >>> rotation_matrix = np.array([[np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)]]) >>> spline.rotate(rotation_matrix) >>> vals = spline(t) >>> plt.plot(vals[:, 0], vals[:, 1], linestyle="--", label="rotated") >>> plt.legend() >>> plt.show()