圆柱 方程

圆柱表面方程

在这里插入图片描述
在这里插入图片描述


看到有写的非常好的了
而且最后用的是超定方程求解,只是我不太明白怎么线性化的,还请知道的朋友不吝赐教。还真是迭代的最小二乘,至于为什么可以又迭代又最小二乘,有人能解释下吗?
线性化就是多元泰勒展开保留线性部分,使用牛顿迭代法求了最小二乘的数值解,防止因解析解求解过于复杂,带来的无法解或计算量大的问题。
迭代是因为每次计算使用的部分参数并不是精确参数,和最小二乘没有什么关系,就是一种解法。
链接:https://blog.csdn.net/qq_30815237/article/details/90405087

其他参考:https://blog.csdn.net/zhangxz259/article/details/86711348
文献:一种圆柱面拟合方法 袁建刚,潘 轶http://www.cnki.com.cn/Article/CJFDTotal-GCKC201712012.html

最小二乘:https://zhuanlan.zhihu.com/p/38128785

球拟合:https://zhuanlan.zhihu.com/p/97036816

  • 空间圆拟合
    球拟合(最小二乘)+ 平面拟合(最小二乘)
    坐标转换到平面 + 二维圆拟合
    https://blog.csdn.net/liyuanbhu/article/details/50889951
    https://blog.csdn.net/weixin_43198881/article/details/103817694

  • 椭圆拟合,避免讨论柱倾斜问题
    https://zhuanlan.zhihu.com/p/143017326

各种拟合模型参考:https://www.geometrictools.com/Documentation/CylinderFitting.pdf
python库:https://pypi.org/project/pyransac3d/
注(2021-8-16):pyransac3d库对圆柱拟合效果不理想

圆柱最小二乘拟合代码

def cylinderFitting(xyz, p, th):
    """
    This is a fitting for a vertical cylinder fitting
    Reference:
    http://www.int-arch-photogramm-remote-sens-spatial-inf-sci.net/XXXIX-B5/169/2012/isprsarchives-XXXIX-B5-169-2012.pdf

    xyz is a matrix contain at least 5 rows, and each row stores x y z of a cylindrical surface
    p is initial values of the parameter;
    p[0] = Xc, x coordinate of the cylinder centre
    P[1] = Yc, y coordinate of the cylinder centre
    P[2] = alpha, rotation angle (radian) about the x-axis
    P[3] = beta, rotation angle (radian) about the y-axis
    P[4] = r, radius of the cylinder

    th, threshold for the convergence of the least squares

    """
    x = xyz[:, 0]
    y = xyz[:, 1]
    z = xyz[:, 2]

    def fitfunc(p, x, y, z): return (- np.cos(p[3])*(p[0] - x) - z*np.cos(p[2])*np.sin(p[3]) - np.sin(
        p[2])*np.sin(p[3])*(p[1] - y))**2 + (z*np.sin(p[2]) - np.cos(p[2])*(p[1] - y))**2  # fit function

    def errfunc(p, x, y, z): return fitfunc(
        p, x, y, z) - p[4]**2  # error function

    est_p, success = leastsq(errfunc, p, args=(x, y, z), maxfev=1000)
    print("拟合状态:",success)
    return est_p

参考:http://www.int-arch-photogramm-remote-sens-spatial-inf-sci.net/XXXIX-B5/169/2012/isprsarchives-XXXIX-B5-169-2012.pdf
https://www.geometrictools.com/Documentation/CylinderFitting.pdf

  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值