# How to find opposite and adjacent lengths of a right triangle given the hypotenuse and angle?

I'm writing a few functions for a JavaScript game engine. Is it possible to calculate the length of the legs of a right triangle given ONLY the length of the hypotenuse and an angle?

-

Well, yes, I believe so. Use the sin formula: $$c=\dfrac{b}{\sin B}=\dfrac{a}{\sin A}\\ \implies b=c\sin B,\quad a=c\sin A$$ Given $\angle A\text{ or }\angle B$ we can calculate the other angle (right triangle).

-
Gotta love the good ol' ASA. Thanks for the memory jog! – Jesse Millar Apr 16 '14 at 1:07
@JesseMillar Yes, well, I was teaching some basic trig. to my friends, and so this popped up to my mind immediately! – Sanath K. Devalapurkar Apr 16 '14 at 1:08

Two words for you: sine and cosine

-
As nice as it would be if this worked, I don't believe it will in the programming sphere. For example, Math.sin(45) in JavaScript returns 0.8509035245341184. Unless there's some way to break that decimal into the opposite and adjacent values, it won't do me any good. – Jesse Millar Apr 16 '14 at 1:04
Hmm, then I think you should specify that in the question, because then you would get answers like these. – The very fluffy Panda Apr 16 '14 at 1:06
Three words? sine, and, cosine! :-) – Sanath K. Devalapurkar Apr 16 '14 at 1:08
@PandaBear This was the first question I've ever asked on Stack. Thanks for the tip. :) – Jesse Millar Apr 16 '14 at 1:08
@SanathDevalapurkar sine and cosine are in bold, mind you! ;-) – The very fluffy Panda Apr 16 '14 at 1:12