How the Arctan Calculator (Inverse Tangent) works
Arctan (inverse tangent, written arctan(x) or tan⁻¹(x)) answers the question: what angle has this tangent? Given a y value (rise) and an x value (run), this calculator computes θ using the two-argument arctangent, θ = atan2(y, x), which is the standard, quadrant-aware generalization of arctan used throughout mathematics, physics, and programming.
Formula and method
The plain single-argument arctan(y/x) only sees a ratio, so it cannot distinguish a point in the first quadrant from its mirror image in the third — both (3, 4) and (-3, -4) divide to the same 0.75, but they point in opposite directions. atan2(y, x) fixes this by inspecting the sign of y and x separately:
- If x > 0: θ = arctan(y/x), giving a result between -90° and 90°.
- If x < 0 and y ≥ 0: θ = arctan(y/x) + 180°.
- If x < 0 and y < 0: θ = arctan(y/x) - 180°.
- If x = 0 and y > 0: θ = 90°. If x = 0 and y < 0: θ = -90°.
- If x = 0 and y = 0: undefined — there is no direction to measure.
The result is a full angle between -180° and 180° (-π and π radians), measured counterclockwise from the positive x-axis, matching the JavaScript Math.atan2(y, x) convention this calculator uses internally.
Common sources of error
- Argument order: atan2 takes y first, then x — swapping them flips the result around the 45° line.
- Confusing arctan(y/x) with atan2(y,x): when x is negative, the two differ by exactly 180°.
- Mixing degrees and radians: this calculator shows both, but downstream formulas (like Math.sin/Math.cos in most programming languages) expect radians.
Checking your result
Recompute tan(θ) with a scientific calculator — it should match the displayed ratio y/x (except when x = 0, where the ratio is undefined but θ is still ±90°). Also check that the sign of θ matches the quadrant: positive x and y should give an angle between 0° and 90°, while negative x and positive y should land between 90° and 180°.
Applications
Arctan and atan2 show up whenever a direction or slope needs to become an angle: finding a roof pitch or ramp angle from rise and run, computing the heading between two points in navigation or robotics, finding the phase angle of a complex number or an AC circuit's impedance, and orienting graphics or game objects toward a target.