How to find if the points fall in a straight line or not?

Solution 1:

if slopes of lines with any two point will be same , then they are co-linear

i.e. $$\frac{y_2-y_1}{x_2-x_1}=\frac{y_3-y_1}{x_3-x_1}$$

Solution 2:

Another way: a certain cross product must be zero, or $$ \left( (x_2-x_1)\hat{i}+(y_2-y_1)\hat{j}\right) \times \left((x_3-x_1) \hat{i}+(y_3-y_1)\hat{j}\right)=\vec{0}$$

$$\implies (x_2-x_1)(y_3-y_1)-(y_2-y_1)(x_3-x_1) = 0$$

Solution 3:

Any two points are collinear in the cartesian plane and form an equation of the form $ax+by=c$. Simply test any two distinct pairs of numbers, find the associate $a$ and $b$, and see if they are the same.

Solution 4:

Translate the points to $(0,0)$, $(x_2-x_1,y_2-y_1)$, $(x_3-x_1,y_3-y_1)$. Now, the condition is equivalent to the linear dependence of $(x_2-x_1,y_2-y_1)$, $(x_3-x_1,y_3-y_1)$, i.e.: $$\left|\matrix{x_2-x_1&y_2-y_1\cr x_3-x_1&y_3-y_1}\right| = 0.$$