如何从位于给定球体表面的点云中获取所有点

How to get all the points from point cloud residing on the surface of a given sphere

我有一个由 PointXYZRGB 组成的点云。我在 3D space 中定义了一个球体 s,因此已知以下内容-

  1. 球体 s 的中心 o(x, y, z)
  2. 球体的半径 r s

我想获取位于给定球体表面的点云的所有点。

std::vector<PointXYZRGB> getAllSurfacePoints(
                         pcl::PointCloud<pcl::PointXYZRGB> cloud){
}

尝试调用此函数一次以删除内部点,然后再次调用此函数以删除外部点。

pcl::PointCloud<pcl::PointXYZI>::Ptr 
passThroughFilterSphere(pcl::PointCloud<pcl::PointXYZI>::Ptr cloud, 
pcl::PointXYZI sphereCenterPoint, const double radius, bool remove_outside)
    {
        pcl::PointCloud<pcl::PointXYZI>::Ptr  filteredCloud(new pcl::PointCloud<pcl::PointXYZI>);
        float distanceFromSphereCenterPoint;
        bool pointIsWithinSphere;
        bool addPointToFilteredCloud;
        for (int point_i = 0; point_i < cloud->size(); ++point_i)
        {
            distanceFromSphereCenterPoint = pcl::euclideanDistance(cloud->at(point_i), sphereCenterPoint);
            pointIsWithinSphere = distanceFromSphereCenterPoint <= radius;
            addPointToFilteredCloud = (!pointIsWithinSphere && remove_outside) || (pointIsWithinSphere && !remove_outside);
            if (addPointToFilteredCloud){
                filteredCloud->push_back(cloud->at(point_i));
            }
        }
        return filteredCloud;
    }