simplify.py 文件源码

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

项目:pyhiro 作者: wanweiwei07 项目源码 文件源码
def points_to_spline_entity(points, smooth=.0005, count=None):
    from scipy.interpolate import splprep

    if count is None: 
        count = len(points)
    points = np.asanyarray(points)
    closed = np.linalg.norm(points[0] - points[-1]) < tol.merge 

    knots, control, degree =  splprep(points.T, s=smooth)[0]
    control = np.transpose(control)
    index = np.arange(len(control))

    if closed:
        control[0] = control[[0,-1]].mean(axis=0)
        control = control[:-1]
        index[-1] = index[0]

    entity = BSpline(points = index, 
                     knots  = knots,
                     closed = closed)

    return entity, control
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号