splinebox.spline_curves.Spline.

moving_frame#

Spline.moving_frame(t, method='frenet', initial_vector=None, shift=None)#

Compute a moving frame (local orthonormal coordinate system) along the spline.

This method computes either the Frenet-Serret frame or the Bishop frame [2] for the spline. A moving frame [1] consists of three orthonormal basis vectors at each point on the curve. The Frenet-Serret frame is derived from the curve’s derivatives but may twist around the curve. The Bishop frame eliminates this twist, providing a zero-torsion alternative.

Parameters:
tnp.array or float

A 1D array of parameter values or a single parameter value at which to evaluate the frame.

methodstr, optional

The type of moving frame to compute. Options are:

  • “frenet”: The classical Frenet-Serret frame, based on tangent, normal, and binormal vectors.

  • “bishop”: A twist-free frame that requires an initial orientation.

Default is “frenet”.

initial_vectornp.array or None, optional

For the Bishop frame, an initial vector that is orthogonal to the tangent vector at t[0]. This vector determines the initial orientation of the basis, which is propagated along the curve without twisting. If None, the method computes a suitable initial vector automatically. This parameter is ignored when method="frenet".

shiftfloat or None

Not all splines are C2 or C1. If any of the t values are at non-differentiable locations, the shift will be applied to them. If shift is None an error will be raised. Usually, a very small shift is sufficient.

Returns:
framenp.array

A 3D numpy array with shape (len(t), 3, 3). The dimensions are:

  • The first axis corresponds to the parameter values in t.

  • The second axis contains the three basis vectors at each t: [tangent, normal, binormal] for “frenet” or equivalent vectors for “bishop”.

  • The third axis contains the components of each basis vector in 3D space.

Raises:
RuntimeError

If the spline is not defined in 3D or if the Frenet frame cannot be computed due to inflection points, straight segments, or undefined tangent/normal vectors.

ValueError

If the initial vector for the Bishop frame is not orthogonal to the tangent at t[0], or if an invalid method is specified.

Notes

  • The Frenet frame is not defined at points where the curve has zero curvature, such as straight segments or inflection points. In these cases, the Bishop frame is recommended.

  • For closed curves, check for discontinuities of the Bishop frame.

References

Examples

We start by creating a 3D spline.

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

       [[ 0., -1.,  0.],
        [ 1.,  0.,  0.],
        [-0.,  0.,  1.]],

       [[ 0.,  1.,  0.],
        [-1.,  0.,  0.],
        [ 0., -0.,  1.]]])

Moving Frames

Moving Frames