栏目分类:
子分类:
返回
终身学习网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
终身学习网 > IT > 软件开发 > 后端开发 > Python

Python numpy 多点拟合平面

Python 更新时间:发布时间: 百科书网 趣学号
  • 向量及平面方程理解
  • 可视化完整版代码见github链接
def planefit(points):
    '''
    todo:   1.generate Auditory canthus line plane
            2.
            --- Ax + By + C = z
                get A B C 
    reference:  https://github.com/SeaTimeMoon/PlaneFit/blob/master/Example1.py
    '''
    xs = []
    ys = []
    zs = []
    for i in range(len(points)):
        xs.append(points[i][0])
        ys.append(points[i][1])
        zs.append(points[i][2])
    tmp_A = []
    tmp_b = []
    for i in range(len(xs)):
        tmp_A.append([xs[i], ys[i], 1])
        tmp_b.append(zs[i])
    b = np.matrix(tmp_b).T
    A = np.matrix(tmp_A)
    fit = (A.T * A).I * A.T * b
    # print("%f x + %f y + %f = z" % (fit[0], fit[1], fit[2]))
    return np.array(fit[0]), np.array(fit[1])
def main():
	points = [[379.5,97.5,16],[230.8,87.9,19],[412.5,248.5,3],[134.5,220.5,8]]
	planefit(points)
if __name__=="__main__":
	main()

其他方法
reference1
reference2
reference3

转载请注明:文章转载自 www.051e.com
本文地址:http://www.051e.com/it/1033826.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 ©2023-2025 051e.com

ICP备案号:京ICP备12030808号