Given a line, calculate a perpendicular line to make a T shape I am working with SVG vector graphics, and I want to make a dynamic T shape by adding a perpendicular line. I have a line with two points (4,17) and (11,3). How can I figure out (x1,y1) and (x2,y2)? The distance between (x1,y1) and (x2,y2) is 10, and the midpoint of the new line is (11,3)

 A: The slope between the given points is
$$
m = \frac{3 - 17}{11 - 4} = -2
$$
The slope of the perpendicular line is
$$
m' = -\frac{1}{m} = \frac 12
$$
Define 
$$
\Delta x = \cos(\arctan(m')) = \frac{1}{\sqrt{(m')^2 + 1}} = \frac{2}{\sqrt{5}}\\
\Delta y = \sin(\arctan(m')) = \frac{m'}{\sqrt{(m')^2 + 1}} = \frac{1}{\sqrt{5}}
$$
The coordinates of the points you want is given by
$$
(x_1,y_1) = (11 - 5 \Delta x, 3 - 5 \Delta y)\\
(x_2,y_2) = (11 + 5 \Delta x, 3 + 5 \Delta y)
$$
A: Let $A(x_1, y_1)$ and $B(x_2, y_2)$. The line from (4, 17) to (11, 3) has a slope of $\frac{17-3}{4-11}=\frac{14}{-7}=-2$. Thus the line AB has a slope $s$ satisfying the following equation: $-2*s=-1$ (since the lines are perpendicular). This leads to $s=\frac{1}{2}$. The points A and B can then be found by starting at (11, 3) and just using our slope of $\frac12$. Every step of 1 unit to the right is coupled with $\frac12$ units up, which covers a distance of $\sqrt{1^2+\frac12^2}=\sqrt{1.25}$. The total distance from (11, 3) to B is 5. Thus, covering a distance of 5 requires $\frac{5}{\sqrt{1.25}}$ steps. This corresponds with $\frac{5}{\sqrt{1.25}}$ units to the right and half that upwards.
Similar reasoning can be used to find A.
