"JD" <jd*******@yahoo.comwrote in message

news:ra******************@newssvr13.news.prodigy.n et...

Hi,

There are about 10+ 3-D points on the same line. I want to find the two

end points from these points. The efficiency is not an issue because there

are only 10 points or so. I just need a cleaner code to do it. Should I

use an STL set to store the distances among them and then retrieve the max

distance from the last element in the set? Then the question is how to

know which points are associated with this max distance? Your help is

appreciated.

Any of the x,y or z coordinates that change will help you. If the x

coordinate changes, just find the point with the min and max x and you have

the end points. x may not change though (if the line runs along the x axis)

then you could use the y or z. You don't really need to do any math, just

detemine which of the 3 coordinates (out of any) that are changing. You

could also sort by some arbitrary method and use the max and min of that

also. The normal method I use for sorting 3d points is in pseudo code:

operator<

if ( x1 < x2 )

return true;

else if ( x1 == x2 )

if ( y1 < y2 )

return true;

else if ( y1 == y2 )

if ( z1 < z2 )

return true;

return false;