boost: intersection line poly geometry

I want to calculate the intersection point between a line:

l := direction * x + origin for x e R or x e [0,R+)

and a default Boost polygon. In the documentation I only found the possibility to get the intersection with a line Segment (fixed start and end point)

At the moment I am using boost geometry and for intersection : http://www.boost.org/doc/libs/1_57_0/libs/geometry/doc/html/geometry/reference/algorithms/intersection.html

Did I miss anything? Or do you know some boost function which I can use to solve my Problem.


I tried a workaround with:

I am using boost 1.56 and get the error that this is not implemented yet. Do you know where I can found a list of which intersection are implemented? Or do know have some new idea?

 

Boost.Geometry doesn't have an intinite Line or Ray concept. So indeed you need to use a Segment or Linestring for this. Using Segment indeed looks as the best way but it just may be not supported by intersection() now. You can create a ticket with a feature request if you need it badly. For now you could use Linestring instead of a Segment to define a line. To store a result you could either use MultiLinestring or a vector of Points. In the second case you'll get the intersection points so AFAIU exactly what you need:

typedef boost::geometry::model::d2::point_xy<double> Point;
typedef boost::geometry::model::linestring<Point> Linestring;
typedef boost::geometry::model::polygon<Point> Polygon;

Linestring ls;
Polygon poly;
std::vector<Point> result;
boost::geometry::intersection(ls,poly,result);

If the above didn't compile you should use more recent version of Boost.

You probably shouldn't create a Linestring containing double's lowest/max. It's because you'd get massive numeric errors. The closer the points of a segment the better. You could for instance manually calculate points of the segment being an intersection of a line and Polgon's bounding box or bounding sphere, etc.

Boost.Geometry doesn't have an intinite Line or Ray concept. So indeed you need to use a Segment or Linestring for this. Using Segment indeed looks as the best way but it just may be not supported by intersection() now. You can create a ticket with a feature request if you need it badly. For now you could use Linestring instead of a Segment to define a line. To store a result you could either use MultiLinestring or a vector of Points. In the second case you'll get the intersection points so AFAIU exactly what you need:

typedef boost::geometry::model::d2::point_xy<double> Point;
typedef boost::geometry::model::linestring<Point> Linestring;
typedef boost::geometry::model::polygon<Point> Polygon;

Linestring ls;
Polygon poly;
std::vector<Point> result;
boost::geometry::intersection(ls,poly,result);

If the above didn't compile you should use more recent version of Boost.

You probably shouldn't create a Linestring containing double's lowest/max. It's because you'd get massive numeric errors. The closer the points of a segment the better. You could for instance manually calculate points of the segment being an intersection of a line and Polgon's bounding box or bounding sphere, etc.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值