What is arctangent?

Initial disclaimer: This is by no means intended to be a full-blown explanation of trigonometry or its functions. This is just a helpful service to everyone who is coming to arctangent.net presumably seeking help with this particular function.

arctangent (atan or tan-1 on some calculators) is used to calculate the angles of a right triangle. It works opposite of the tangent function. While tangent will find the ratio of the two sides of a right triangle when given an angle, arctangent can find the angle given the ratio.

To illustrate this point, consider we have a right triangle with sides a and b. The typical way to use the tangent function is to calculate the ratio of the two non-hypotenuse sides of a right triangle, such as a and b, from the angle (θ) between b and the hypotenuse. One would normally see this indicated as tan(θ) = b / a.

arctangent, as the name may imply, works in the opposite direction; you can use the ratio b / a to find the angle θ, such that θ = atan(b / a). With tan and atan at your disposal, you can use basic algebra to find the missing value when you have any two of a, b, or θ.

Those two equations are extremely useful when calculating polar coordinates from an x and y value. All you effectively need to realize is that a ≡ x and b ≡ y. Unfortunately, due to the limitations of the arctangent function, this will only work when x is positive. If it's negative, 180 degrees (or π) should be subtracted from the resulting angle. If x equals zero then the angle will be ± 90 degrees (or ± π / 2).

This can be pseudo-programmatically described like so:

if (x > 0) then
  θ = atan(y / x)
else if (x < 0) then
  θ = atan(y / x) - π
else if (x == 0) then
  if (y > 0) then
    θ = π
  else if (y < 0) then
    θ = -π
  else if (y == 0) then
    θ is undefined

This can be annoyingly complicated to plop into the middle of other code, but fortunately most programming languages provide a function to do this for you, such as atan2() in ANSI c, while most scientific calculators will have a button (labelled as R -> P) to convert from rectangular to polar coordinates for you, and provide both the radius (the hypotenuse) and theta.

Thanks, Adam, for the correction

Back to the arctangent.net home