0

I am attempting to find the center of several sets of 3D points on a sphere. Each set is comprised of three or more points that fall on the arc of a circle, but not perfectly as they have been supplied by an object detection algorithm, so there is some inherent error in these points. This is for me where the difficulty lies, I cannot simply solve the equations, I need to try and minimize variance in radius to this point across all three-point sets.

Currently, I am calculating a plane of best fit for each set of points. By calculating the radius (perpendicular distance) to this normal for each set and determining the variance I can figure out which plane (normal or center of rotation) fits all three sets the best. I am also doing this for an average of the three planes and for two planes after throwing out the plane that agrees least with the other two. So I am getting a pretty decent approximation currently.

My question is, does anyone know how to implement in Python some sort of function that can help me find a normal vector through these points that minimize the variance in radius for all sets. I suspect this won't be far off my current approximation, but am looking for the most accurate solution to this problem.

The picture below shows the results of what I am currently doing. The pink points represent the points I am using, labeled 0,1,2 for each set of points. The blue dots represent the normal vector projected to the surface of the sphere. The orange is the average of the three blue dots projected to the surface of the sphere. Ignore green they are not relevant to this. To minimize the variance my code is currently telling me that axis (blue dot) 0 results in the least variance in radius for the data set as a whole, but I highly doubt it is the best fitting point.

Circle centers do not agree the best due to errors in the supplied points

Circle centers agreeing quite well in this one

Adrian
  • 468
  • 2
  • 6
  • 15
Bvdb89
  • 11
  • 3
  • Why are you attempting a plane of best fit? If the points are placed arbitrarily on the sphere I don't see how that could lead to a meaningful estimation of sphere centroid. – Reinderien Jul 09 '22 at 01:09
  • Have you tried getting a mean of your points, using that as an initial centroid, using the mean distance from the centroid as the radius, and then running a naive non-linear optimization via scipy? – Reinderien Jul 09 '22 at 01:11
  • You describe "the normal vector projected to the surface of the sphere". Are the original points on the surface of the sphere or not? If not, where are they? – Reinderien Jul 09 '22 at 01:16
  • @Reinderien - They are not arbitrary points. Each set (0, 1, 2) are the locations of a point on a spinning ball for several frames. In the case of image 1, we have 3 frames of 3 points. In image 2 we have 5 frames of 3 points. Since each set is a single point rotating about an axis (which is what I am trying to find), the points from each set will plot on a plane perpendicular to the rotation axis. For each set we have a unique plane, but the planes would all be parallel resulting in the same spin axis (normal vector of the plane). This can be seen in image 2 where we have better agreement. – Bvdb89 Jul 12 '22 at 18:04
  • @Reinderien The points are on the surface of the ball. I only say projected (probably the wrong word) since I am representing the 3D points in a 2D image, but all of these points have an x,y,z coordinate from the center of the ball. I have not tried scipy, I do believe that a method like that is the best approach. I have zero idea how to implement that, but I would likely use my current estimated rotation axis as a starting point. Will let you know how it goes. – Bvdb89 Jul 12 '22 at 18:09
  • I understand a lot better now; the "spinning" description was crucial. However, given that this is StackOverflow, you need an MVCE, which means that you need some example datapoints and the code for your current approach. – Reinderien Jul 13 '22 at 01:03
  • Do you have information on the amount of rotation between each frame? Does it increase linearly? – Reinderien Jul 13 '22 at 02:15
  • 1
    @Reinderien I did some looking into the SciPy minimize function and it solved this problem for me beautifully. I minimized the variance in "radius" from the predicted rotation axis to each point in each set and it worked perfectly. When I had good results with my old method, this new approach agreed perfectly and it handles the situations where errors are much larger very well also. Thanks for the nudge in that direction, I was hesitant to go that path, but glad I did! – Bvdb89 Jul 14 '22 at 21:53

0 Answers0