NDCurves

cite: https://github.com/loco-3d/ndcurves

type1: Bezier

A Bezier curve is a parametric curve defined by a set of control points ${p_0, p_1, …, p_n}$ where $n$ is its order. The curve passes through its first and last control point.

All Bezier curves of order superior to 3 can be represented as Bezier curves of order 3 or less joined end-to-end, where the last control point of one curve coincides with the first control point of the next curve.

type2: Polynomials

Represents a polynomial of an arbitrary order defined on the interval $[t_{min}, t_{max}]$.

type3: Cubic Hermite

A cubic hermite spline is a polynomial curve of degree 3, defined by its initial and final positions and velocities : $P_i$, $P_{i+1}$ and $m_i$, $m_{i+1}$.

Piecewise Curves $\equiv{ Cf_0, Cf_1,…Cf_N}$

  • $Pc$ defined in $[Tmin, Tmax]$
  • $\forall i \subset {0,1,…,N}$, $Cf_i$ is defined in $[Tmin_i, Tmax_i]$
  • $\forall i \subset {0,1,…,N}$, $Tmax_i = Tmin_{i+1}$
  • $Tmin_0=Tmax$ and $Tmax_N=Tmax$

Example

from ndcurves import (
    CURVES_WITH_PINOCCHIO_SUPPORT,
    Quaternion,
    SE3Curve,
    SO3Linear,
    bezier,
    bezier3,
    convert_to_bezier,
    convert_to_hermite,
    convert_to_polynomial,
    cubic_hermite_spline,
    curve_constraints,
    exact_cubic,
    piecewise,
    piecewise_SE3,
    polynomial,
)
import numpy as np


print("test_piecewise_cubic_hermite_curve")
# To test :
# - Functions : constructor, min, max, derivate, add_curve, is_continuous
points = np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]).transpose()
tangents = np.array([[2.0, 2.0, 2.0], [4.0, 4.0, 4.0]]).transpose()
time_points0 = np.array([[0.0, 1.0]]).transpose()
time_points1 = np.array([[1.0, 2.0]]).transpose()
a = cubic_hermite_spline(points, tangents, time_points0)
b = cubic_hermite_spline(points, tangents, time_points1)
pc = piecewise(a)
pc.append(b)
print(f"{pc.min()}, {pc.max()}")
print(f"{pc(0)}, {pc(1)}, {pc(2)}")
print("======")
for i in range(21):
    print(pc(0.1*i))