-1

If there are two coordinates of a unit circle, e.g. $x=0$, $ y=1$, I know this is $\frac{\pi}{2}$.

How can I calculate pi for any two coordinates, even if they are not places on the unit circle, like $x=1.23$, $y=-0.1$?

  • 1
    Are you asking about how to calculate the angle from positive $x$-axis to a given point on the unit circle? Then $(x,y)=(0,1)$ has the angle $\pi/2,$ not $2/\pi.$ – md2perpe May 27 '20 at 21:30
  • Sorry, that was a typo. Of course it's pi/2 – user1406177 May 27 '20 at 21:32
  • 3
    "How can I calculate pi..." - I assume you mean "how can I compute the angle..." In general, if $(x,y) \neq (0,0)$, the angle from the positive $x$ axis to $(x,y)$ is given by the four-quadrant arctangent function. –  May 27 '20 at 21:34
  • It can be good to know that the angle unit used here is called radians. A right angle, $90 {}^\circ,$ is $\frac{\pi}{2}$ radians. To mathematicians radians is more natural than the degrees. – md2perpe May 27 '20 at 21:51

2 Answers2

1

"How can I calculate pi..." - I assume you mean "how can I compute the angle..." In general, if $(x,y)\neq(0,0)$, the angle from the positive $x$ axis to $(x,y)$ is given by the four-quadrant arctangent function. – Bungo 1 min ago

Chris Culter
  • 26,806
1

If I am understanding correctly, you can take the $\text{atan2}(\frac{y}{x})$ in radians. Where the atan2 function is defined in this link:

atan2 link look under the heading Definition and computation.

So if you have the numbers you have above:

$\text{atan2}(\frac{-0.1}{1.23}) = -0.081 \text{ radians}$

to get the number of pi radians, we can divide by $\pi$

$-.081= \pi x$

this implies that:

$x = -.0258$

So you want the number $-.0258\pi$

  • This doesn't work for points in the left half plane or on the $y$ axis. You need the four-quadrant arctangent function to cover the whole plane (excluding the origin, of course). –  May 27 '20 at 21:50
  • 1
    that's fair ill change by arctangent function to the piecewise one – atul ganju May 27 '20 at 21:58