I'm trying out boost::geometry and was wondering if you know an efficient way to get the normal vector of the polygon at an intersection between a polygon and a line segment. Or something like the line segment_id of the segment where it intersects? I do understand how to get the normal if I would have the line Segment of the polygon which contains the intersection. So far I have
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/assign.hpp>
int main(){
typedef model::d2::point_xy<double> point;
typedef model::ring< point > ring;
typedef model::polygon< point > polygon;
typedef model::multi_polygon< polygon > polygons;
typedef model::box< point > box;
typedef boost::geometry::model::segment<point> Segment
//Polygon
std::string poly_file="poly.dat";
polygon poly;
read_wkt(poly_file, poly);
correct(poly);
//Line segment:
polygon lineSegment;
point p0(0,-0.5);
point p1(1,0.5);
append(lineSegment, p0);
append(lineSegment, p1);
//Getting intersection:
std::vector<point> output;
intersection(poly, lineSegment, output);
//Getting normal vector at this intersection point
// ???
return 0;
}
Thanks a lot in advance!