If I have three points, is there an easy way to tell if they are collinear? [duplicate]

Points $(a,b)$, $(m,n)$, and $(x,y)$ are selected at random. What is the quickest/easiest way to tell if they are collinear? At first I thought it was a matter of comparing slopes but that doesn't appear to be enough.


Solution 1:

"At first I thought it was a matter of comparing slopes"... and you were right!

If the line segments AB and BC have the same slope, then A, B, C are necessarily collinear. Note that there are some corner cases having to do with whether B is the "middle" point or not (in which case the slopes will still be equal), and one having to do with vertical lines (where some formula you use to compute slope might divide by 0).

Putting all this together, the points $(a, b)$, $(m, n)$ and $(x, y)$ are collinear if and only if $$(n-b)(x-m) = (y-n)(m-a)$$ (comes from $\frac{n-b}{m-a} = \frac{y-n}{x-m}$, but not writing it in fraction form to avoid division by $0$).

Solution 2:

The area is zero, in formula $\det \pmatrix{1 &a &b\\ 1 &m &n\\ 1 &x &y}=0$