Methods for showing three points in $\mathbb{R}^2$ are colinear (or not) [closed]

Solution 1:

Since there seems to be some confusion as to the fit of $(-1,8)$ vs. $(-1,-8)$, try to use the other two points.

So say that point $a$ is $(x_1, y_1)$, point $b$ is $(x_2, y_2)$, and we'll start with the assumption that $x_1\neq x_2$.

The general "two-point" formula for the equation of a line (given two points) is given by:

$$(y - y_1) = \frac{(y_2 - y_1)} {(x_2 - x_1)} (x-x_1)\quad\quad\quad(1)$$

where $$\frac{(y_2 - y_1)} {(x_2 - x_1)} = m $$

($m$ represents the slope of the line). You the need to simplify the equation by solving for $y$ and putting the equation, e.g., in slope-intercept form: $y = mx + b$ where $b$ is the $y$-intercept (the value of $y$ when $x = 0$). Then you need then to substitute the $x$-coordinate of the third point for $x$ in the equation, likewise for $y$. If the result, after doing so, is not an equality, then the third point doesn't "satisfy" the equation; in other words, it is therefore not on the line.

If $(-1,8)$ does not satisfy the equation of the line (such that after replacing $x$ and $y$ with the third point's coordinates, the two sides of the equation don't match, try using $(-1,-8)$, and if that works, you need to recheck the method you used to obtain the point $(-1,8)$.

Of course, you can also use the slope-intercept form, after computing the slope, as above: $$y = mx + b$$ To solve for $b$, the $y$-intercept, simply evaluate the equation, putting $x = 0.$ That should give you $y = b$ (at $x = 0$): the point at which the line intersects the $y$-axis.

Caveat:

Now, suppose $x_1 = x_2$. Then what? We certainly cannot use the general two-point formulation given above, since if $x_1=x_2$, then $x_2 - x_1 = 0$, and division by zero is undefined. What do you know about lines for which the slope is undefined?

Such lines are always vertical lines, perpendicular to the $x$-axis, so every $x$-coordinate on such a line is identical. If we can rewrite the equation provided above in (1) as such:

$$(x_2 - x_1)(y - y_1) = (y_2 - y_1)(x-x_1)$$

The left side evaluates to $0$; simplifying gives us the equation $x = x_1.$

Recommendation: if this question is related to your studying for exams etc., it's important to understand how to compute the equation of a line, given two points, given the slope, and also how to easily move back and forth between such forms.

Solution 2:

Here are three tests of collinearity.

Distance Test

This is the first test I learned to check if three points were collinear. It actually tests if one point is between two others. Given three points $(x_1,y_1)$, $(x_2,y_2)$, and $(x_3,y_3)$, the point $(x_2,y_2)$ is between $(x_1,y_1)$ and $(x_3,y_3)$ when $$ |(x_1,y_1)-(x_3,y_3)|=|(x_1,y_1)-(x_2,y_2)|+|(x_2,y_2)-(x_3,y_3)| $$ If any of the three points is between the other two, they are collinear; that is, if any of the distances is the sum of the other two.

$\hspace{3cm}$enter image description here

Area Test

The area of a triangle is given by half the determinant of the vectors of two of the sides. That is, given

$\hspace{4cm}$enter image description here

The area of the triangle is $$ \frac12\det\begin{bmatrix}x_2-x_1&y_2-y_1\\\\x_3-x_1&y_3-y_1\end{bmatrix} $$ The three points are collinear exactly when this area is $0$.

Volume Test

Given three points in $\mathbb{R}^2$, first we move them into $\mathbb{R}^3$, $z=1$ to be precise. Next the volume of the tetrahedron formed by three points and the origin is one sixth the determinant of the three points.

That is, the volume of

$\hspace{3cm}$enter image description here

is $$ \frac16\det\begin{bmatrix}x_1&y_1&1\\x_2&y_2&1\\x_3&y_3&1\end{bmatrix} $$

The volume of a pyramid is one third of the base times the altitude. In the case above, the altitude is $1$. Thus, the points are collinear exactly when this volume is $0$.

Solution 3:

For 3 points to be collinear:

The area of the triangle formed by given 3 points should be ZERO.

Suppose there are three points given A(x1, y1), B(x2, y2) and C(x3, y3). Then

                     x1 y1 1
Area(ABC) = (1/2)det x2 y2 1
                     x3 y3 1

Where det is determinant. So find this determinant, if zero, the given points are collinear otherwise not.

For n points to be collinear:

Input: P1, P2, P3, ... , Pn

Method 1:

  1. For each triplet (P1, P2, P3)
  2. See if these three are collinear using area of the triangle method given above.
  3. Repeat for (P3, P4, P5) and so on till (Pn-2, Pn-1, Pn)
  4. If all triplets are collinear (area = zero) then given n points are collinear.

Method 2:

  1. Find minimum and maximum points with respect to x-coordinate.
  2. Find equation of the line joining these min and max points using two-point formula (credit: amWhy).
  3. For each remaining n-2 points, check whether they all lie (satisfy the equation) on this line.

Food for thought: If you want to find 3 collinear points from given n points then it's rather tough and time complexity is more.

Thanks.