Imagine following scenario:

enter image description here

There is a line segment $|AB|$, point $N$ (somewhere on the line), and a distance $k$.

Now I would like to find coordinates of endpoints of a line segment $|CD|$ that is orthogonal to $|AB|$, passes through point $N$ and the distance between $C$ and $N$ (resp. $D$ and $N$) is $k$.

My approach:

enter image description here

(Let's ignore point $D$, because the solution is principially the same.)

First I calculate the sides of the $ANC$ triangle

$$ d = \|N - A\| \\ h = \sqrt{d^2 + k^2} $$

enter image description here

Then angles of $CAN$ and $BAy$ triangles.

$$ \alpha = \arctan \left( \frac{k}{d} \right) \\ \beta = \arctan \left( \frac{B_y - A_y}{B_x-A_x} \right) $$

And from there I can get the coordinates of point $C$.

$$ C_x = h \cdot \cos \left(\alpha + \beta \right)\\ C_y = h \cdot \sin \left(\alpha + \beta \right)\\ $$

My question:

While the above solution works, it feels very heavy-handed and built just from geometric primitives.

So my question is whether this is possible to do in some cleaner, straight-forward manner with linear algebra. Perhaps I could compute the normal vector and then somehow move it and expand/mirror it?


If $\vec{AB}=(u,v)$, then vector $(-v,u)$ is orthogonal to $\vec{AB}$, so that $$ \vec{CN}={k\over\sqrt{u^2+v^2}}(-v,u). $$

  • $\begingroup$ Excellent! This is so much nicer. :-) (Also to truly answer the question it would be $C = N + CN$, but that is just a minor detail). $\endgroup$ – Peter Uhnak Oct 23 '15 at 9:58
  • $\begingroup$ Yes, and of course $D=N-\vec{CN}$. $\endgroup$ – Aretino Oct 23 '15 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.