JS Built-ins
← Math78 / 215
Mathatan2intermediate

Math.atan2(1, 1) Equals PI/4

πŸ“– 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, 1) returns Math.PI / 4 (45Β°, the first-quadrant diagonal).

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

πŸ’‘ Hints (2)
  • β€’ The point (1, 1) is at 45Β° from the x-axis
  • β€’ Ο€/4 β‰ˆ 0.7854