geometry是boost的一个库,主要擅长做一些比如GIS图形处理,下面是经过成功测试的一段代码。
5 #include <boost/geometry/geometry.hpp>
6 #include <boost/geometry/geometries/point.hpp>
7 #include <boost/geometry/geometries/point_xy.hpp>
15 namespace bg = boost::geometry;
16 //namespace bgi = boost::geometry::index;
17
18 typedef bg::model::d2::point_xy<long> GPoint;
19 typedef bg::model::segment<GPoint> GSegment;
||| 93 GPoint a(1, 1);
||| 94 GPoint b(2, 2);
||| 95 std::cout << bg::distance(a, b) << std::endl;
||| 96 GPoint p1(0, 0);
||| 97 GPoint p2(5, 3);
||| 98 GSegment s1(p1, p2);
||| 99 std::cout << bg::distance(a, s1) << std::endl;