# Determining end coordinates of line with the specified length and angle?

I have the point $(x_1, y_1)$, the angle $0 \leq a < 360$ in degrees and the length $l > 0$.

How do I determine the end point $(x_2, y_2)$ if there is a line between $(x_1, y_1)$ and $(x_2, y_2)$ of length $l$ and with angle $a$?

-

$$(x_2,y_2)=(x_1+l\cdot\cos(a),y_1+l\cdot\sin(a)) \; .$$

There is an ambiguity in your question though: what is the reference w.r.t. which the angle is measured? I assumed it's the X-axis, since that seemed the most natural without any further specifications.

-
Maybe you should add a comment on how to make sure that the calculator/computer computes the sine and cosine with respect to $a$ in degrees as opposed to radians and how to convert if necessary. –  t.b. May 16 '11 at 11:50
@Theo: OK, I'll wait a bit to see if the OP asks for it. I deliberately kept the answer to the point with not much details on derivation. It could be a homework question, just as it could be about programming something. –  Raskolnikov May 16 '11 at 11:56

Knowing the length $l$ and the angle $a$ gives you a right triangle with base parallel to the $x$-axis and the hypotenuse is the line itself. From this you can calculate the length of the legs, using trigonometry: denote the length of the leg parallel to the $x$-axis by $X$, and the other one by $Y$. Then, by the law of sine you get: $\frac{X}{\cos a}=\frac{Y}{\sin a}=\frac{l}{\sin \frac{\pi}{2}}=l$. From here you can find $X,Y$. The the end-point will be $(x_2,y_2)=(x_1+X,y_1+Y)$.

-