In contrast to the general refrain, there are various ways to determine (and calculate) the center of a point cloud. You have already proposed the first and most common solution, and I do not claim that something is wrong with this:
centroid = average(x), average(y), average(z)
The “problem” is that it will “distort” your center point depending on the distribution of your points. If, for example, you assume that all of your points are in a cubic box or some other geometric shape, but most of them fall in the upper half, your center point will also shift in that direction.
Alternatively, you can use the mathematical mean (average of the extrema) in each dimension to avoid this:
middle = middle(x), middle(y), middle(z)
You can use this when you care about the number of points, but more about the global bounding box, because all this is the center of the bounding box around your points.
Finally, you can also use median (the element in the middle) in each dimension:
median = median(x), median(y), median(z)
Now this will do the opposite of middle and actually help you ignore outliers in the point cloud and find the center point based on the distribution of your points.
A more and more reliable way to find a “good” center point may be to ignore the upper and lower 10% in each dimension, and then calculate average or median . As you can see, you can define the center point in different ways. Below I will show you examples of two 2D point clouds based on these suggestions.
The blue dot is the middle (middle) center of gravity. The median is shown in green. The middle is shown in red. In the second image, you will see exactly what I said before: the green dot is “closer” to the densest part of the point cloud, and the red dot is even further away from it, taking into account the extreme edges of the point cloud.
