extend a line in both way I have a line segment, passing through the points $A = (100,100), B = (200, 200)$ and I would like to extend it by a certain length in both way. 
I can get the length of the current line segment by
$$\sqrt{(B.x - A.x)^2 + (B.y - A.y)^2} \approx 141.42$$
But from here I don't know what I have to do to extend it equally in both ways.
 A: The equation of a line is $y = mx + b$.  Where $m$ is the slope.
In this line $m = \frac{200 - 100}{200-100} = \frac{100}{100} = 1$
So $y = x + b$.  We can solve for $b$ by plugging in either $(100,100)$ or $(200,200)$ into the equation to get $200 = 200 + b$ or $100 = 100 + b$ so $b = 0$.
So the equation is $y = x$.
Pick a point $(x',y'); y' = x'$ on the line.  If we extend the line so that the $x$ value increases by $h$ then what does the $y$ value increase by?  $y' = x'$ so $y_{new} = x' + h = y' + h$.  So the $y$ value also increases by $h$.
So what does the total distance increase by?  $D((x',y'),(x'+h,y'+h)) = \sqrt{(x'+h - x')^2 + (y'+h - y')^2} = \sqrt{h^2 + h^2} = \sqrt{2h^2} = h\sqrt{2}$.
So if you want to increase the line by $D$ you must extend $x$ (and $y$) by... $D = h\sqrt2 \implies h = D/\sqrt2 = D*\frac{\sqrt 2}{2}$.
====
So for instance, if we want to extend the line $75$ units, we must increase $x$ by $75*\frac{\sqrt 2}{2}$ units to the point $(x = 100 +75*\frac{\sqrt 2}{2}, y = 100 +75*\frac{\sqrt 2}{2})$.
A: So suppose you want to extend this by another $100$, for example. Then you would want to extend it by $a=10$ on both sides.
The current center of the line is at $C = (150,150)$. As you noted, the current length of the segment is $l = 100 \sqrt{2}$. The half line from the center to the extreme is then $l/2 = 50 \sqrt{2}$ and the desired half line would be $50 \sqrt{2} + a/2 = 50 \sqrt{2} + 5$.
Because you are following along the line $y=x$, your diagonal is always (by Pythagorean theorem) exactly $\sqrt{2}$ times the horizontal length you need to move. So the net horizontal length would be
$$
\frac{50\sqrt{2} + a/2}{\sqrt{2}} = 50 + \frac{a\sqrt{2}}{4} = 50 + \frac{5\sqrt{2}}{2}
$$
and the segment would extend from $150$ at the center with endpoints in both $x$ and $y$ of
$$
150 \pm 50 + \frac{a\sqrt{2}}{4} = 150 \pm 50 + \frac{5\sqrt{2}}{2}
$$
