0

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!

  • possible duplicate of [How do I calculate the normal vector of a line segment?](http://stackoverflow.com/questions/1243614/how-do-i-calculate-the-normal-vector-of-a-line-segment) – Cory Kramer Jun 12 '14 at 12:32
  • @Cyber I understand how to compute the normal vector itself. But I'm rather looking for an efficient way to the find the line segment of the polygon with which the line intersects – user3428018 Jun 12 '14 at 12:37

0 Answers0