Example 1 — Basic atan2() usage
This example finds the angle for points in four different areas of the plane.
<?php
echo round(atan2(1, 1), 4) . PHP_EOL;
echo round(atan2(1, -1), 4) . PHP_EOL;
echo round(atan2(-1, -1), 4) . PHP_EOL;
echo round(atan2(-1, 1), 4) . PHP_EOL; How It Works
- atan2(1, 1) is a point in the top-right area, giving 45 degrees (0.7854 radians).
- atan2(1, -1) is in the top-left area, giving 135 degrees (2.3562 radians).
- atan2(-1, -1) is in the bottom-left area, giving -135 degrees (-2.3562 radians).
- atan2(-1, 1) is in the bottom-right area, giving -45 degrees (-0.7854 radians).

