Is there a formal proper way of finding the line between two points?
By that I don't mean the line connecting the two points, I mean a line that runs the same distance away from point 1 and point 2.
To phrase it another way, I want to find the equation of a line that divides the plane into two equal parts, where each of the two points are the same distance from the line.
I drew a picture. In this picture, how do I find the purple line?
It may or not be relevant, but I'm asking because I am trying to learn about Support Vector Machines.
$\endgroup$4 Answers
$\begingroup$Each point on the line has the same distance from point $x_1=(a,b)$ as from point $x_2=(c,d)$. If we say this in equations we get: $$ (x-a)^2 + (y-b)^2 = (x-c)^2 + (y-d)^2 $$ expand
$$ x^2 -2ax + a^2 + y^2 - 2by +b^2 = x^2 -2cx +c^2 + y^2 -2dy +d^2 $$ we can simplify and get final equation $$ 2x(a-c) + 2y(b-d) +c^2 + d^2 -a^2 - b^2 = 0 $$
edit to explain in more detail first equality
If you have two points with coordinates $X=(x,y)$ and $A=(a,b)$ than distance between them is equal to $$ \text{dist}(X,A)=\sqrt{ (x-a)^2 + (y-b)^2 } $$ This is basically Pythagoras theorem. Draw right angle triangle with points $A,B,(x,b)$ than its hypotenuse is line segment connecting $A,B$. Pythagoras theorem calculates length of hypotenuse of right angle triangle.
In your question point on line, denote it $X=(x,y)$, has to have same distance from $A$ as well from $B$ so $$ \text{dist}(X,A) = \text{dist}(X,B) $$ This is almost that equation, you just need to square it.
$\endgroup$ 2 $\begingroup$Let $(x_1,y_1)$ be the coordinates of point $x_1$ and $(x_2,y_2)$ be the coordinates of point $x_2$.
The gradient $m$ of the line connecting them will be
$$m=\frac{y_2-y_1}{x_2-x_1}$$
As the purple line will be perpendicular to the line joining points $x_1$ and $x_2$ (because all points on the purple line will be equidistant from points $x_1$ and $x_2$), its gradient $m'$ will be $$m'=-\frac{1}{m}=\frac{x_1-x_2}{y_2-y_1}$$
Now the point at which the purple line will intersect the line joining $x_1$ and $x_2$ will be the mid-point between $x_1$ and $x_2$:- $$\left(x_1+\frac{1}{2}(x_2-x_1),y_1+\frac{m}{2}(x_2-x_1)\right)=\left(\frac{x_1+x_2}{2},\frac{y_1+y_2}{2}\right)$$
We can find the intercept $c$ of the purple line as follows:- $$\frac{y_1+y_2}{2}=m'\frac{x_1+x_2}{2}+c=\frac{x_1-x_2}{y_2-y_1}\frac{x_1+x_2}{2}+c \\\Rightarrow c=\frac{(y_2^2-y_1^2)-(x_1^2-x_2^2)}{2(y_2-y_1)}=\frac{(x_2^2+y_2^2)-(x_1^2+y_1^2)}{2(y_2-y_1)}$$
Having found the intercept and the gradient, the equation of the purple line can be expressed as:- $$y=\frac{x_1-x_2}{y_2-y_1}x+\frac{(x_2^2+y_2^2)-(x_1^2+y_1^2)}{2(y_2-y_1)}$$
$\endgroup$ 1 $\begingroup$The line goes through the midpoint of the segment $x_1x_2$ which you can find by averaging the coordinates. Its slope is the negative reciprocal of the slope of the segment. You can now use the point slope form.
$\endgroup$ $\begingroup$Method one (geometry): Draw the circle, $C_1$, centered on $x_1$ passing through $x_2$ and the circle $C_2$, centered on $x_2$ passing through $x_1$. These two circles have two intersection, $y_1, y_2$. The line through these two points is a perpendicular bisector of the segment formed by $x_1$ and $x_2$.
Method two (algebraic): We know that one point on the desired line is the midpoint between the two lines, $m = \frac{x_1+x_2}{2}$ and that the slope is $-1/\frac{x_{2(y)} - x_{1(y)}}{x_{2(x)} - x_{1(x)}}$, where the subscript "$(x)$" means the $x$-coordinate of the point and similarly for "$(y)$". I.e., the desired slope is perpendicular to the rise over the run of the given points. Assuming that the slope between $x_1$ and $x_2$ is not zero, so that the slope of the desired line is not infinity, the resulting slope is $-\frac{x_{2(x)} - x_{1(x)}}{x_{2(y)} - x_{1(y)}}$. Putting these into point-slope form $$ \frac{y-m_{(y)}}{x-m_{(x)}} = -\frac{x_{2(x)} - x_{1(x)}}{x_{2(y)} - x_{1(y)}}$$ and solving this for $y$ is trivial.
$\endgroup$