#include #include typedef std::pair Point; BOOST_GEOMETRY_REGISTER_POINT_2D(Point, double, boost::geometry::cs::cartesian, first, second); //#define point1 first //#define point2 second struct Segment { Point point1; Point point2; }; namespace boost { namespace geometry { namespace traits { template<> struct tag { typedef segment_tag type; }; template<> struct point_type { typedef Point type; }; template<> struct indexed_access { static inline double get(Segment const& segment) { return segment.point1.first; } }; template<> struct indexed_access { static inline double get(Segment const& segment) { return segment.point1.second; } }; template<> struct indexed_access { static inline double get(Segment const& segment) { return segment.point2.first; } }; template<> struct indexed_access { static inline double get(Segment const& segment) { return segment.point2.second; } }; }}} int main() { Segment s1 = { Point(0, 0), Point(2, 2) }; Segment s2 = { Point(0, 2), Point(2, 0) }; std::cout << "len: " << boost::geometry::length(s1) << std::endl; std::vector out; boost::geometry::intersection(s1, s2, out); std::cout << "intersection: " << out[0].first << ", " << out[0].second << std::endl; }