|  | Home | Libraries | People | FAQ | More | 
Calculate azimuth of a segment defined by a pair of points.
template<typename Point1, typename Point2> auto azimuth(Point1 const & point1, Point2 const & point2)
| Type | Concept | Name | Description | 
|---|---|---|---|
| Point1 const & | Type of the first point of a segment. | point1 | First point of a segment. | 
| Point2 const & | Type of the second point of a segment. | point2 | Second point of a segment. | 
Azimuth in radians.
Either
            #include <boost/geometry.hpp>
          
Or
            #include <boost/geometry/algorithms/azimuth.hpp>
          
The function azimuth is not defined by OGC.
| ![[Note]](../../../../../../../../doc/src/images/note.png) | Note | 
|---|---|
| PostGIS contains an algorithm ST_Azimuth with the same functionality. See the PostGIS documentation. | 
The algorithm calculates the azimuth of a segment defined by a pair of points.
| ![[Note]](../../../../../../../../doc/src/images/note.png) | Note | 
|---|---|
| The result is in radians. | 
Shows how to calculate azimuth
#include <iostream> #include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> int main() { typedef boost::geometry::model::d2::point_xy<double> point_type; point_type p1(0, 0); point_type p2(1, 1); auto azimuth = boost::geometry::azimuth(p1, p2); std::cout << "azimuth: " << azimuth << std::endl; return 0; }
Output:
azimuth: 0.785398