JS Built-ins
← Math76 / 215
Mathatan2beginner

Math.atan2(0, 1) Equals Zero

πŸ“– Usage Example
// Angle from positive x-axis to point (x, y)
Math.atan2(1, 1)   // β†’ 0.7853... (Ο€/4)
Math.atan2(0, 1)   // β†’ 0

Use Math.atan2(y, x) to compute the angle of a point from the origin, correctly handling all quadrants.

Math.atan2(y, x)

Returns the angle (in radians) between the positive x-axis and the point (x, y). Math.atan2(0, 1) returns 0.

Challenge: Use Math.atan2() and verify its result for the point (1, 0).

πŸ’‘ Hints (2)
  • β€’ Note: argument order is (y, x), not (x, y)
  • β€’ The point (1, 0) is on the positive x-axis, so the angle is 0