bezierTools.py 文件源码

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

项目:otRebuilder 作者: Pal3love 项目源码 文件源码
def approximateQuadraticArcLengthC(pt1, pt2, pt3):
    # Approximate length of quadratic Bezier curve using Gauss-Legendre quadrature
    # with n=3 points for complex points.
    #
    # This, essentially, approximates the length-of-derivative function
    # to be integrated with the best-matching fifth-degree polynomial
    # approximation of it.
    #
    #https://en.wikipedia.org/wiki/Gaussian_quadrature#Gauss.E2.80.93Legendre_quadrature

    # abs(BezierCurveC[2].diff(t).subs({t:T})) for T in sorted(.5, .5±sqrt(3/5)/2),
    # weighted 5/18, 8/18, 5/18 respectively.
    v0 = abs(-0.492943519233745*pt1 + 0.430331482911935*pt2 + 0.0626120363218102*pt3)
    v1 = abs(pt3-pt1)*0.4444444444444444
    v2 = abs(-0.0626120363218102*pt1 - 0.430331482911935*pt2 + 0.492943519233745*pt3)

    return v0 + v1 + v2
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号