JS Built-ins
← Math77 / 215
Mathatan2intermediate

Math.atan2(1, 0) Equals PI/2

πŸ“– 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)

Math.atan2(1, 0) returns Math.PI / 2 (90Β°, pointing up the y-axis).

Challenge: Verify that Math.atan2(1, 0) equals Ο€/2.

πŸ’‘ Hints (2)
  • β€’ The point (0, 1) is on the positive y-axis, giving angle 90Β° = Ο€/2
  • β€’ atan2 handles the division-by-zero case that plain atan cannot