How can I define a point that is perpendicular to the endpoints on a line segment?

68 Views Asked by At

I am currently working on a problem statement that requires me to find the equation of a line given two points, normalizing the line ($Ax+By+C = 0$) and then introducing a third point into the same plane. I have to find the distance of this third point to the line itself when it is normalized.

I am currently using this as reference: Distance from a point to a line

Pretty easy to follow. One minor question (before moving on) is if I take the sum of equation (2') in the reference:

dist$(P,\text{line}) = Au + Bv + C$

This should be the distance of the point to the line correct? (Just making sure)

The next big question I have is how can I find *two distinct lines that are perpendicular to the endpoints $P_1$ and $P_2$ that are creating a line/segment? What I want to do is find two lines perpendicular to the endpoints and then say that if the projection of the third point ($Q$) lies outside of these, then it is not on the line created by P1 and P2. This is going to be done through code but I don't need help on that.

I figured that I could plug in coordinates of the two endpoints like equation 2' but this doesn't seem right.

1

There are 1 best solutions below

0
On

If I understand the latter part of your question correctly, you want, given a line segment from a point $P_1$ to a point $P_2$ in the plane, to have points $Q_1$ and $Q_2$ in the plane, such that the line segment of the points $\overline{Q_1Q_2}$ intersects $\overline{P_1P_2}$ and is perpendicular.

Using vector notation this can easily be done by letting for example $m = \frac{1}{2}(p_1+p_2)$, $d = \frac{1}{2}(p_2-p_1)$ and setting $q_1 = m + \begin{bmatrix}0&-1\\1&0\end{bmatrix}\cdot d$ and $q_2 = m + \begin{bmatrix}0&1\\-1&0\end{bmatrix}\cdot d$.

In words: we first calculate the midpoint $m$ and a direction $d$ of the line-segment $\overline{P_1P_2}$ and then we calculate the points obtained by going from the midpoint in the direction of $d$ rotated clockwise / counterclockwise.