Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm trying to write in java a function which finds the angles, in degrees, between 2 vectors, according to the follow equation - $$\cos{\theta} = \frac{\vec{u} \cdot \vec{v}}{\|\mathbf{u}\|\|\mathbf{v}\|}$$

but in java the Math.acos method returns the angle radians, so what I have to do after I calculate $\frac{\vec{u} \cdot \vec{v}}{\|\mathbf{u}\|\|\mathbf{v}\|}$, to get it in degrees?

share|improve this question
3  
Multiply the value in radians by $\frac{360}{2\pi}$. You'll get the value in degrees. –  Jonathan Y. Aug 10 '13 at 20:18
add comment

2 Answers

up vote 3 down vote accepted

You can compute the angle, in degrees, by computing the angle in radians, and then multiplying by

$\dfrac {360}{2\pi} = \dfrac {180\; \text{degrees}}{\pi\; \text{radians}}$:

$$\theta = \arccos\left(\frac{\vec{u} \cdot \vec{v}}{\|\mathbf{u}\|\|\mathbf{v}\|}\right)\cdot \frac {180}{\pi}$$

share|improve this answer
    
$\color{blue}{great~work}\color{green}{+}^\color{red}{+}\color{orange}{+}$ @amWhy –  Software Aug 10 '13 at 23:46
add comment

After calculating the value in radians, simply multiply by $\frac {180}{\pi}$ to convert it into degrees.

share|improve this answer
add comment

Your Answer

 
discard

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.