Find a point that is perpendicular to line

91 Views Asked by At

I have two directional points. Point A going to point B. Each point has an X and Y coordinate.

What I am trying to do is find a point C, with distance d. The two constraints are that C has to be perpendicular to where B ends AND BC is always 90 degrees anti-clockwise relative to AB.

Essentially what I am asking is what are the steps to solve for C using those two constraints.

enter image description here

2

There are 2 best solutions below

15
On BEST ANSWER

If $A$,$B$ are represented as complex numbers $a,b$, then $C$ is represented by the complex number $c$, where $c$ is given by $$c=b+(di)\frac{b-a}{|b-a|}$$

0
On

The current answer may be mathematically elegant, but for the people who like to think geometrically:

You have the points $A$ and $B$. The "line from $A$ to $B$" is given as the vector $S$, which is just the difference of the points:

$$S = B - A$$

Divide this vector by its length, to obtain a unit vector, and then scale this unit vector with with $d$, to obtain the vector $T$ with the desired length:

$$T = \frac{S}{|S|} \cdot d$$

Then rotate this vector by 90 degrees counterclockwise, to obtain vector $U$, which is the "line from $B$ to $C$":

$$U = (-T_y, T_x)$$

Finally, add this vector to point $B$ to obtain the result:

$$C = B + U$$