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?

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}$