curve.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:CElegansBehaviour 作者: ChristophKirst 项目源码 文件源码
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);
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号