Extend line in xy-plane when start/endpoint and direction is known 
Years ago my math was in very good shape, it isn't anymore.
I have a line in the $xy$-plane, I have coordinates for start and end points. I also know the direction (angle in $xy$) of the line. Now I want to extend the line with the amount $d$ in both ends. Is there a simple formula for that? 
 A: It is very easy with vectors (you don't even need the angle !).
Say the endpoints of this line segment are $A$ and $B$, which have respectively coordinates $(x_1, y_1)$ and $(x_2, y_2)$.
The coordinates of the vector $\vec{AB}$ are $(x_2 - x_1, y_2 - y_1)$.
The norm of this vector is $AB = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$.
Introduce $\vec{v} := \frac{1}{AB} \vec{AB}$. It has norm 1, its coordinates are $(\frac{x_2 - x_1}{AB}, \frac{y_2 - y_1}{AB})$.
Say $A'$ is the new startPoint, and $B'$ the new endpoint. We must have 
$\vec{AA'} = -d \vec{v}$ and $\vec{BB'} = d \vec{v}$.
From this, we get :
$x'_1 = x_1 - d\cdot \frac{x_2 - x_1}{AB}$
$y'_1 = y_1 - d\cdot \frac{y_2 - y_1}{AB}$
$x'_2 = x_2 + d\cdot \frac{x_2 - x_1}{AB}$
$y'_2 = y_2 + d\cdot \frac{y_2 - y_1}{AB}$ 
A: Assuming that x runs positive right direction and y runs positive upwards. You need to mark it.
Resolve the extension part(or line segment) and  add/subtract  directly to coordinate of the $(x,y)$ component at either end:
$$ x2' = x2 - d \cos (\pi-\alpha) $$
$$ y2' = y2 + d \sin (\pi-\alpha) $$
$$ x1' = x1 + d \cos (\pi-\alpha) $$
$$ y1' = y1 - d \sin (\pi-\alpha) $$
