ST_Angle

Syntax

DOUBLE ST_Angle(GEOPOINT point1, GEOPOINT point2, GEOPOINT point3)

description

Enter three point, which represent two intersecting lines. Returns the angle between these lines. Point 2 and point 1 represent the first line and point 2 and point 3 represent the second line. The angle between these lines is in radians, in the range [0, 2pi). The angle is measured clockwise from the first line to the second line.

ST_ANGLE has the following edge cases:

  • If points 2 and 3 are the same, returns NULL.
  • If points 2 and 1 are the same, returns NULL.
  • If points 2 and 3 are exactly antipodal, returns NULL.
  • If points 2 and 1 are exactly antipodal, returns NULL.
  • If any of the input geographies are not single points or are the empty geography, then throws an error.

example

  1. mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1));
  2. +----------------------------------------------------------------------+
  3. | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 1.0)) |
  4. +----------------------------------------------------------------------+
  5. | 4.71238898038469 |
  6. +----------------------------------------------------------------------+
  7. 1 row in set (0.04 sec)
  8. mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1));
  9. +----------------------------------------------------------------------+
  10. | st_angle(st_point(0.0, 0.0), st_point(1.0, 0.0), st_point(0.0, 1.0)) |
  11. +----------------------------------------------------------------------+
  12. | 0.78547432161873854 |
  13. +----------------------------------------------------------------------+
  14. 1 row in set (0.02 sec)
  15. mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0));
  16. +----------------------------------------------------------------------+
  17. | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(1.0, 0.0)) |
  18. +----------------------------------------------------------------------+
  19. | 0 |
  20. +----------------------------------------------------------------------+
  21. 1 row in set (0.02 sec)
  22. mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0));
  23. +----------------------------------------------------------------------+
  24. | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 0.0)) |
  25. +----------------------------------------------------------------------+
  26. | NULL |
  27. +----------------------------------------------------------------------+
  28. 1 row in set (0.03 sec)
  29. mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0));
  30. +--------------------------------------------------------------------------+
  31. | st_angle(st_point(0.0, 0.0), st_point(-30.0, 0.0), st_point(150.0, 0.0)) |
  32. +--------------------------------------------------------------------------+
  33. | NULL |
  34. +--------------------------------------------------------------------------+
  35. 1 row in set (0.02 sec)

keywords

ST_ANGLE,ST,ANGLE