Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|cite|improve this question
up vote 3 down vote accepted

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).

share|cite|improve this answer
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

enter image description here

share|cite|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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