Find point at distance d perpendicular to endpoint A of given line segment AB Given a line segment from point $A$ to point $B$, how do you find a point $A_2 $ that is perpendicular to the point $A$ at a distance $d$ from $A$? Points $A, B$ and distance $d$ are given.
I cant seem to figure out the correct way to solve this problem and my linear algebra / geometry are a bit rusty. It seems as though using Orthogonal Projection may work since I have the distance but I cant figure out the location of the point. Any ideas?
Take a look at the following Diagram for clarification. 

 A: I would use the angles, get the slope of the line as follows:
$$
\theta = \arctan\frac{y_B-y_A}{x_B-x_A}
$$
Then the coordinates of $A_2$ would be
$$
x_{A_2} = x_A+d \cos(90+\theta) \\
y_{A_2} = y_A+d \sin(90+\theta) 
$$
A: Rephrased question: Find the end point of a right triangle, one of whose sides is the given line segment.
Let's restrict this problem in 2-Dimension space. This problem can be solved in three steps:


*

*Find the direction of the perpendicular vector,

*Find the size of a vector with specified length in that direction, 

*Add that vector to the starting point, namely $A$. 
Step 1. 
Say $AB=(x_1,y_1),$ then any other vector $(x_2,y_2)$ perpendicular to $AB$ will share the property that
$$ x_1\cdot x_2 + y_1\cdot y_2 = 0$$
then you will have $$\frac{x_2}{y_2} = -\frac{y_1}{x_1}$$
Step 2. 
While the length of the vector is defined as $l^2$-norm, i.e., if the distance in $y$ direction is 1, the length of the vector is $$\sqrt{\left(\frac{y_1}{x_1}\right)^2+1}$$ 
If you need your distance to be $d$, then the vector should be $$\pm\left(-\frac{y_1}{x_1}\frac{d}{\sqrt{\left(\frac{y_1}{x_1}\right)^2+1}}, \frac{d}{\sqrt{\left(\frac{y_1}{x_1}\right)^2+1}} \right)$$
Step 3. 
If you have the position of your start point of $A = (x_a, y_a)$ then the other point of this vector would be $$\left( x_a\mp\frac{y_1}{x_1}\frac{d}{\sqrt{\left(\frac{y_1}{x_1}\right)^2+1}}, y_a \pm \frac{d}{\sqrt{\left(\frac{y_1}{x_1}\right)^2+1}} \right)$$
A: So I have come to a solution. Let me know if you guys see any flaws. It's based off of Ahmed S. answer.
Since we know the length of the line AA2 and we can calculate the slope of the line AB we can find the coordinates of A2.


*

*Find the slope of the perpendicular line AA2. 


*

*Slope of AA2 = (1 / m) = (B.x - A.x) / (B.y - A.y)


*Find theta. 


*

*Theta = arctan (slope of AA2)


*A2.x = A.x - d * cos(theta)

*A2.y = A.y + d * sin(theta)


Find A2 image
A: I'm going to use "vectors" (which are just pairs of numbers in this case, which I'll write in brackets), which can be added to points termwise, so that 
$$
(1, 2) + [3, 5] = (4, 7)
$$
Vectors can also be multiplied by numbers, termwise, so that
$$
\frac{1}{2}[3, 5] = [3/2, 5/2].
$$
You can think of vectors as representing, in the plane, movement in some direction, so that $[3, 5]$ means "move 3 units to the right, 5 units up," and when you do so, it makes a lot of sense to add a vector to a point: you take the point (which was $(1, 2)$ in my example) and move it $3$ units right and $5$ units up, and you end up  at $(4, 7)$. When you multiply a vector by $\frac{1}{2}$, you make the displacement half as big, and so on. 
One last thing: I wrote 
$$
(1, 2) + [3, 5] = (4, 7)
$$
so show how to add a vector to a point, but we can do some algebra (moving the $(1,2)$ to the right hand side) and write
$$
[3, 5] = (4, 7) - (1, 2),
$$
and now you've got a really nice thing: the "difference" of two points is a vector. In fact, if you have points $P$ and $Q$, then $v = Q - P$ is exactly the vector that moves $P$ to $Q$ (which we often draw as an arrow pointing from $P$ to $Q$). 
Here's a really useful fact: if you have a vector $[a, b]$, and at least one of $a$ and $b$ is nonzero, then the vector 
$$
[-b, a]
$$
is perpendicular to $[a, b]$, and is rotated 90 degrees counterclockwise from $[a, b]$. 
The other useful fact is that if you have a vector $[a, b]$ of some length, then 
$$
\frac{1}{\sqrt{a^2+b^2} [a, b]
$$
is a vector pointing in the same direction, but with length $1$. (A length-1 vector is called "unit vector" sometimes.) 

OK, with all that in mind, let's return to your problem. First, let's let
$$
w = B - A
$$
That's the vector that moves $A$ to $B$, or an arrow from $A$ pointing towards $B$. To make this concrete, I'm going to pick 
$$
A = (1, 4)\\
B = (5, 6)
$$
So now 
$$
w = B - A = (5, 6) - (1, 5) = [4, 1]
$$
for our example. We can produce a unit vector in the same direction as $w$ by the trick mentioned above: we multiply by $1$ over a square root. If $w = (a, b)$, we compute
$$
v = \frac{1}{\sqrt{a^2 + b^2}} [a, b].
$$
In our example, this comes out to 
$$
v = \frac{1}{\sqrt{4^2 + 1^2}}[4, 1] = [\frac{4}{\sqrt{17}}, \frac{1}{\sqrt{17}}].
$$
If we then use the first trick -- swap the two entries and negate the first, we get
$$
v^\perp =  [-\frac{1}{\sqrt{17}}, \frac{4}{\sqrt{17}}]
$$
which is an arrow of length $1$ pointing perpendicular to the line from $A$ to $B$. 
In the general case, we get 
$$
v^\perp = \frac{1}{\sqrt{a^2 + b^2}} [-b, a].
$$
If we multiply this by $d$ and add it to the point $A$, we get the point $A'$: 
$$
A' = A + d v^\perp.
$$
In our example, picking $d = 2$, that gives us 
\begin{align}
A' 
&= (1, 4) + 2[-\frac{1}{\sqrt{17}}, \frac{4}{\sqrt{17}} ]\\
&= (1, 4) + [-\frac{2}{\sqrt{17}}, \frac{8}{\sqrt{17}} ]\\
&= (1-\frac{2}{\sqrt{17}}, 4 + \frac{8}{\sqrt{17}}).
\end{align}
This works perfectly as long as the vector $w$ isn't $[0,0]$ (which we need to make the "perpendicular" vector). But this just means "as long as the points $A$ and $B$ are different", which is obviously necessary -- if they're the same, the question doesn't really make sense. 
