From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding the center of rotation of a set of 3D points

Solved!
Go to solution

I'm struggling a bit on this one. I have a set of 3D points and I'm trying to best fit the center of rotation of the movement. So far I have best fitted the plane of these points but finding it for the center of rotation (or the circle) is another game. I've done some search for an algorithm but came up empty. Precision is very important so I would like to avoid doing a best fit on a best fit.

 

Anybody who have done something similar?

 

Ben64

0 Kudos
Message 1 of 20
(5,024 Views)

Have you looked at "Fitting on a Sphere.vi"?

0 Kudos
Message 2 of 20
(4,977 Views)

@DSPGuy wrote:

Have you looked at "Fitting on a Sphere.vi"?


Yes, and the result doesn't make any sense. It is kind od expected since  the points are a circle arc. In this case it can be fitted on a lot a different spheres. I would need the specific case where the data points arc in located on the sphere great circle.

 

Ben64

0 Kudos
Message 3 of 20
(4,970 Views)

Once you have the plane, reduce the data to 2D in that plane. Fitting to a sphere will fit to a circle if the data is 2D (z=0). See if that is more accurate.

 

What result do you expect? Is this simulated (where you know the answer) or real data (where you don't)..

 


@ben64 wrote:

@DSPGuy wrote:

Have you looked at "Fitting on a Sphere.vi"?


Yes, and the result doesn't make any sense. It is kind od expected since  the points are a circle arc. In this case it can be fitted on a lot a different spheres. I would need the specific case where the data points arc in located on the sphere great circle.

 


Fittng on a shpere is a direct method (not iterative) and I thought it would find the correct answer in your case (great circle). For example, in the 2D case, (fitting a circle) there are an infinite number of spheres that fit the data, but it will pick the smallest (where the center is also in that plane).

0 Kudos
Message 4 of 20
(4,956 Views)

altenbach a écrit :

Once you have the plane, reduce the data to 2D in that plane. Fitting to a sphere will fit to a circle if the data is 2D (z=0). See if that is more accurate.

 

What result do you expect? Is this simulated (where you know the answer) or real data (where you don't)..

 


@ben64 wrote:

@DSPGuy wrote:

Have you looked at "Fitting on a Sphere.vi"?


Yes, and the result doesn't make any sense. It is kind od expected since  the points are a circle arc. In this case it can be fitted on a lot a different spheres. I would need the specific case where the data points arc in located on the sphere great circle.

 


Fittng on a shpere is a direct method (not iterative) and I thought it would find the correct answer in your case (great circle). For example, in the 2D case, (fitting a circle) there are an infinite number of spheres that fit the data, but it will pick the smallest (where the center is also in that plane).


These are real data from an Optitrack system, in the attached vi you can see that the center from Fit on a Circle.vi (the blue dot) doesn't came close to the expected position.

 

I was looking at transforming the 3D problem into a 2D one by rotating and translating the fitted plane to the x-y plane. I would then find the best fit center and perform the inverse transformation to get the result.

 

One question that I have is should I use the projection of the data points on the best fit plane or the actual points are close enough? (I would think I should to get more precision but maybe it would be easyer with no significant precision loss to just set the z component to 0 after the plane transformation).

 

Ben64

0 Kudos
Message 5 of 20
(4,950 Views)

Wearing my Math Hat, this sounds like a straight-forward problem, but I'm not sure I completely understand the question.  What is the Model you are trying to fit?  It sounds (to me) like you expect that the points should (ideally) lie on a circle that lies in some plane in 3-D space.  The question is, what measure are you trying to minimize?  Do you want the 3-D least-squared distance of each point for the chosen circle, regardless of whether the points are in the plane of the circle or not?  Do you want to fit the best plane, project the points onto this plane, then do the 2-D problem of least-squared distance to the circle?  Is there another measure I haven't mentioned?

 

Can you provide a set of points to use as test data?  [It wouldn't be so difficult to generate our own, but there's nothing like "Real Data", as opposed to "Alternative Data" ...]

 

Bob Schor

0 Kudos
Message 6 of 20
(4,943 Views)

The problem with your data is that is is nearly linear. I am sure if you had a slight banana in there, it would all fall in place.

 

How many bits are in the sensor data?

 

If I do "fitting on a sphere" and validate by measuring all distances to the center from each real point, they are well within 5 decimal digits of the fitted radius (see picture). If your digitizer is 16 bits, this is well within digital noise. I doubt you can find a better "center".

 

 

Even finding the best plane seems like an ill posed problem given the nearly linear data.

0 Kudos
Message 7 of 20
(4,941 Views)

Here is my test VI with your original data.

 

Download All
0 Kudos
Message 8 of 20
(4,933 Views)

Also looking at your linear algebra, the matrix you are inverting has a condition number of 6E7, meaning you can lose up top ~8 digits in accuracy (use this tool). Again, what is the resolution of the position sensors?

0 Kudos
Message 9 of 20
(4,927 Views)

Just got some reply from a collegue who's taking the measurements, note that this is very preliminary stuff since we just got the Optitrack system and are still getting familiar with it. According to my collegue the accuracy on the position is around 5 mil, the position from the file I used to populate the string control are in meter (the joy of working with 2 systems!).

 

Attached is a more completed set of data.

Marker 2201 data.png

Ben64

0 Kudos
Message 10 of 20
(4,888 Views)