如何将PointCloud移至坐标中心?

发布于 2025-02-10 09:13:01 字数 272 浏览 0 评论 0原文

我有一个点云,上面有位置(x,y,z)和颜色(r,g,b) 但是积分距离坐标很远的距离很大:

问题是:哪种算法可以用来将所有点放置到坐标中心?我的猜测是创建翻译矩阵并乘以所有点云指向它,但是我无法确定此矩阵应包含的内容

I have a PointCloud which have points with position(x, y, z) and color(r, g, b)
But points lays in big distance from coordinates canter:
Image

Question is: what algorithm can be used to place all points to coordinates center? My guess is to create translation matrix and multiply all pointCloud points to it, but I can't determine what this matrix should contain

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨后咖啡店 2025-02-17 09:13:01

刚找到答案。需要与这样的东西找到尖端的质量中心:

    var summX: Float = 0
    var summY: Float = 0
    var summZ: Float = 0

    for point in points {
        summX += point.x
        summY += point.y
        summZ += point.z
    }

    let middleX = summX / Float(points.count)
    let middleY = summY / Float(points.count)
    let middleZ = summZ / Float(points.count)

    let centerOfMass = Float3(x: middleX, y: middleY, z: middleZ)

然后创建翻译矩阵

”在此处输入图像描述

,最后将所有点乘以此矩阵

    let translationMatrix = float4x4(simd_float4(x: 1, y: 0, z: 0, w: -centerOfMass.x),
                                     simd_float4(x: 0, y: 1, z: 0, w: -centerOfMass.y),
                                     simd_float4(x: 0, y: 0, z: 1, w: -centerOfMass.z),
                                     simd_float4(x: 0, y: 0, z: 0, w: 1))

    let translatedPoints = points.map { point in
        return point * translationMatrix
    }

Just found an answer. Need to find center of mass of PointCloud with something like this:

    var summX: Float = 0
    var summY: Float = 0
    var summZ: Float = 0

    for point in points {
        summX += point.x
        summY += point.y
        summZ += point.z
    }

    let middleX = summX / Float(points.count)
    let middleY = summY / Float(points.count)
    let middleZ = summZ / Float(points.count)

    let centerOfMass = Float3(x: middleX, y: middleY, z: middleZ)

Then create translation matrix

enter image description here

And finally multiply all points to this matrix

    let translationMatrix = float4x4(simd_float4(x: 1, y: 0, z: 0, w: -centerOfMass.x),
                                     simd_float4(x: 0, y: 1, z: 0, w: -centerOfMass.y),
                                     simd_float4(x: 0, y: 0, z: 1, w: -centerOfMass.z),
                                     simd_float4(x: 0, y: 0, z: 0, w: 1))

    let translatedPoints = points.map { point in
        return point * translationMatrix
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文