To determine if three points are on the same line, check to see if the slop of a line connecting the first two points is the same as the slope of the line connecting the last two points. This would mean that
(y2 - y1) / (x2 - x1) == (y3 - y1) / (x3 - x1)
If this is true, then the three points are collinear. However this is complicated by roundoff error - the equation above will seldom be
exactly true. But you want to know if it is
close to being true. You can rearrange the equation to get
((y2 - y1) * (x3 - x1)) / ((x2 - x1) * (y3 - y1)) == 1
And then do something like
Math.abs( ((y2-y1) * (x3-x1)) / ((x2-x1) * (y3-y1)) - 1) < 1e-10
to see if the values are "cloase enough" to a straight line.
Of course, this is just for three points. For your situation you will have to write some loops to consider all possible combinations of points, and check them each with the above
test. Enjoy...