Search code examples
c++point-cloud-librarypoint-clouds

Slice angle out of point cloud


I'm looking to slice a 90 degree section, 45 degrees either side of origin along an axis, out of a 270 degree point cloud from a lidar scan using PCL. My thinking so far would be to look for two points (in the x and z directions in my case, as these axes represent the horizontal and depth directions respectively) whose ratio matches the tangent of 45 degrees.

However I'm not sure how to go about this in an efficient way; I was thinking of using a kd tree, but I'm not sure how to search it for a ratio of two points/two points that have the ratio.

Does anyone know how to go about this, or perhaps have a better method of doing it?

Thanks!


Solution

    • You will have to touch each point once to see if it lives in the slice or not. Building a kd-tree will have higher computational complexity than this, so there is no point building it.

    • This problem is made easier by the fact that the point cloud is axis-aligned. Your intuition regarding the tangent is correct. You basically just need to check, for each point, if x is more than z. For the general case where the angle is not necessarily 45 degrees, you will normalise the xz coordinates of the point and use the dot product angle formula to calculate the angle with the z axis.