Sorting collinear Points on a 3D Line

geometry

I have a list of points in 3 space that are all collinear. I need to sort the list of points so I may process them in order. I don't care or we don't have a choice which end of the line we start from since the line directions vary and there is no sense of beginning or end–they are lines! However, I will have many lists of collinear points that will be parallel to each other and I would like the sort method to yield sorting them in the same direction.

An early attempt, which is flawed, was to pick one of the points in the list and compute distance (magnitude) to all other points and then use this distance to sort. However, that might only work if the chosen point was on one end or the other. Thanks

Best Answer

You could pick one point, then calculate the point that is furthest away from it. That furthest point is an "end point" and you could sort on distance from it.