# How to measure the goodness of fit of a 3D line?

I have data points in 3D space, and I'd like to quantify how well they conform to a straight line.

Specifically, this is a body tracking problem. I have multiple options available for the 3D positions of body parts. For example, there are points for the knee, calf, and foot. I need to select one correct point for each body part. Since the knee to foot is a rigid link, the correct points should be fairly aligned. I want to reject combinations of knee/calf/foot positions which are not in a straight enough line.

The line of best fit for 3D points can be found using the method described in this thread. Is there a metric for how well this line fits the data?

• Please explain how a line can be a "best fit" to points in three dimensions. How did you find it? In what sense is it intended to fit the points?
– whuber
Commented Mar 6, 2016 at 16:43
• I used the information on this thread - the line of best fit passes through the centroid of the points, and is in the direction of a certain eigenvector. My specific problem is for body tracking. For example, I have options for the position of the knee, calf, and foot. I need to select correct points from these options. The knee, calf and foot data points should be in a roughly straight line. I want to reject combinations of points that are not "straight enough". Commented Mar 6, 2016 at 20:04
• I think it's a great question (+1). However, I recommend (a) editing it to include the details in your comment and (b) downplaying $R^2$, because it's neither applicable nor relevant to your problem.
– whuber
Commented Mar 6, 2016 at 21:13