Curve.py 文件源码

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

项目:Splipy 作者: sintefmath 项目源码 文件源码
def length(self, t0=None, t1=None):
        """ Computes the euclidian length of the curve in geometric space

        .. math:: \\int_{t_0}^{t_1}\\sqrt{x(t)^2 + y(t)^2 + z(t)^2} dt

        """
        (x,w) = np.polynomial.legendre.leggauss(self.order(0)+1)
        knots = self.knots(0)
        # keep only integration boundaries within given start (t0) and stop (t1) interval
        if t0 is not None:
            i = bisect_left(knots, t0)
            knots = np.insert(knots, i, t0)
            knots = knots[i:]
        if t1 is not None:
            i = bisect_right(knots, t1)
            knots = knots[:i]
            knots = np.insert(knots, i, t1)

        t = np.array([ (x+1)/2*(t1-t0)+t0 for t0,t1 in zip(knots[:-1], knots[1:]) ])
        w = np.array([     w/2*(t1-t0)    for t0,t1 in zip(knots[:-1], knots[1:]) ])
        t = np.ndarray.flatten(t)
        w = np.ndarray.flatten(w)
        dx = self.derivative(t)
        detJ = np.sqrt(np.sum(dx**2, axis=1))
        return np.dot(detJ, w)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号