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've been learning about the unit circle, sine, cosine, and the like in my introduction to trigonometry course, but I'm drawing a blank here.

If I have a circle centered at the origin, with radius r and point(x,y), how do I find the measure of the angle from (r,0) to (x,y)?

For example, if the radius is 1 and the point is ($-\frac{1}{\sqrt{2}}$,$\frac{1}{\sqrt{2}}$), the number I would want is 135 degrees, or the equivalent in radians.

edit: Actually, I would also appreciate a formula to calculate this measurement between any two points on a circle.

share|improve this question
2  
Use the inverse trigonometric functions. You know the $\sin$ of the angle in your example is $1/\sqrt2$ (the $y$-coordinate of the point). What angle in the second quadrant has that as its $\sin$? You should recognize that it's one of the "special angles". Formally, you could take $\arcsin(1/\sqrt2)$. But this would give you the angle in the first quadrant with the proper $\sin$. Then you'd find the equivalent angle in the second quadrant. –  David Mitra Mar 6 '12 at 3:44
    
@DavidMitra, That was my train of thought: to use the inverse of the tangent function and other bits of logic to determine the angle based on quadrant, but I was hoping for a formula that was more direct. –  mowwwalker Mar 6 '12 at 3:47
1  
Unfortunately, that's what you'd have to do. That's because the inverse trig functions are functions, they only return one value. But there are usually two distinct angles in $[0,2\pi)$ that have a given value of $\sin$ (or $\tan$, etc...). –  David Mitra Mar 6 '12 at 3:52
add comment

1 Answer

up vote 2 down vote accepted

There is a two variable function, called $\text{atan2}$ in C, that may do the job for you, if something like it is built into the piece of software that you are using.

For some discussion of the $\text{atan2}$ function, see this.

Roughly speaking, $\text{atan2}(y,x)$ is $\arctan(y/x)$ if $x$ is positive. If $x$ is negative, and $y\ge 0$, then $\text{atan2}(y,x)=\pi+\arctan(y/x)$, while if $x<0$ and $y<0$, then $\text{atan2}(y,x)=-\pi+\arctan(y/x)$. And so the program won't blow up, $\text{atan2}(y,x)$ is defined in the reasonable way when $x=0$.

In particular, $\text{atan2}(1/\sqrt{2},-1/\sqrt{2})=3\pi/4$, precisely what you wanted. You may be less happy with $\text{atan2}(-1/\sqrt{2},-1/\sqrt{2})$.

Warning: While many software packages implement an $\text{atan2}$-like function, the name and the syntax are not universal. Sometimes $x$ and $y$ are interchanged. The details for Fortran, C, Mathematica, MATLAB, and Excel, to mention some examples, are slightly different!

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.