def from_tck(self, tck, points = None):
"""Change spline parameter and knot structure using a tck object returned by splprep or splrep
Arguments:
tck (tuple): t,c,k tuple returned by splprep
points (int, array or None): optional sample points pecification
"""
t,c,k = tck;
self.degree = k;
# set knots
self._knots = t[k+1:-k-1];
self._knots_all = t;
self._nparameter = self._knots.shape[0] + k + 1;
#set parameter
if isinstance(c, list):
c = np.vstack(c);
elif isinstance(c, np.ndarray) and c.ndim == 1:
c = np.vstack([c]);
c = c[:,:self._nparameter].T;
self.ndim = c.shape[1];
self._parameter = c[:];
#set points
if points is not None:
self.set_points(points);
# values and projection matrix will need to be updated after change of the knots
self._values = None;
self._projection = None;
self._projection_inverse = None;
############################################################################
### Spline getter
评论列表
文章目录