def phi(self, points = None):
"""Returns a Spline representing the tangent angle along a 2d curve
Arguments:
points (int, array or None): sample points used to determine the phi
Returns:
Spline: spline of phi
"""
if self.ndim != 2:
raise RuntimeError('phi angle can only be computed for 2d curves');
points = self.get_points(points, error = 'cannot determine sample points needed for the calculation of phi');
#get the tangents and tangent angles
tgs = splev(points, self.tck(), der = 1);
tgs = np.vstack(tgs).T;
phi = np.arctan2(tgs[:,1], tgs[:,0]);
phi = np.mod(phi + np.pi, 2 * np.pi) - np.pi;
#return Spline(phi, points = self.points, knots = self.knots, degree = self.degree - 1);
tck = splrep(points, phi, s = 0.0, k = self.degree + 1);
return Spline(tck = tck, points = points);
评论列表
文章目录