Shortcuts

pypose.chspline

class pypose.chspline(points, interval=0.1)[source]

Cubic Hermite Spline, a piecewise-cubic interpolator matching values and first derivatives.

Parameters:
  • points (Tensor) – the sequence of points for interpolation with shape […, point_num, dim].

  • interval (float) – the unit interval between interpolated points. We assume the interval of adjacent input points is 1. Therefore, if we set interval as 0.1, the interpolated points between the points at \(t\) and \(t+1\) will be \([t, t+0.1, ..., t+0.9, t+1]\). Default: 0.1.

Returns:

the interpolated points.

Return type:

Tensor

The interpolated points are evenly distributed between a start point and a end point according to the number of interpolated points. In this function, the interpolated points are also evenly distributed between the start point and end point.

Denote the starting point \(p_0\) with the starting tangent \(m_0\) and the ending point \(p_1\) with the ending tagent \(m_1\). The interpolated point at \(t\) can be defined as:

\[\begin{aligned} p(t) &= (1-3t^2+2t^3)p_0 + (t-2t^2+t^3)m_0+(3t^2-2t^3)p_1+(-t^2+t^3)m_1\\ &= \begin{bmatrix} p_0, m_0, p_1, m_1 \end{bmatrix} \begin{bmatrix} 1& 0&-3& 2\\ 0& 1&-2& 1\\ 0& 0& 3&-2\\ 0& 0&-1& 1 \end{bmatrix} \begin{bmatrix}1\\ t\\ t^2\\ t^3\end{bmatrix} \end{aligned}\]

Note

The implementation is based on wiki of Cubic Hermite spline.

Examples

>>> import torch
>>> import pypose as pp
>>> points = torch.tensor([[[0., 0., 0.],
...                         [1., .5, 0.1],
...                         [0., 1., 0.2],
...                         [1., 1.5, 0.4],
...                         [1.5, 0., 0.],
...                         [2., 1.5, 0.4],
...                         [2.5, 0., 0.],
...                         [1.75, 0.75, 0.2],
...                         [2.25, 0.75, 0.2],
...                         [3., 1.5, 0.4],
...                         [3., 0., 0.],
...                         [4., 0., 0.],
...                         [4., 1.5, 0.4],
...                         [5., 1., 0.2],
...                         [4., 0.75, 0.2],
...                         [5., 0., 0.]]])
>>> waypoints = pp.chspline(points, 0.1)
../../_images/CsplineR3.png

Fig. 1. Result of Cubic Spline Interpolation in 3D space.

Docs

Access documentation for PyPose

View Docs

Tutorials

Get started with tutorials and examples

View Tutorials

Get Started

Find resources and how to start using pypose

View Resources