相交线Poly Boost几何 [英] Intersection Line Poly boost geometry

查看:113
本文介绍了相交线Poly Boost几何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算一条线之间的交点:

I want to calculate the intersection point between a line:

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

和默认的Boost多边形.在文档中,我仅发现有可能与线段(固定的起点和终点)相交

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)

此刻,我正在使用boost几何体并用于交集: http://www.boost.org/doc/libs/1_57_0/libs/geometry/doc/html/geometry/reference/algorithms/intersection.html

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:

  typedef boost::geometry::model::d2::point_xy<double> Point;
  typedef boost::geometry::model::segment<Point> Segment;
  Segment AB( Point{1,1*std::numeric_limits<double>::lowest()},Point{0,1*std::numeric_limits<double>::max()});
  boost::geometry::model::polygon<Point> poly;
  poly.outer().push_back(Point{0,0});
  poly.outer().push_back(Point{10,0});
  poly.outer().push_back(Point{10,10});
  poly.outer().push_back(Point{0,10});
  poly.outer().push_back(Point{0,0});
  std::vector<Segment> result;
  boost::geometry::intersection(AB,poly,result);

我正在使用Boost 1.56,并得到尚未实现的错误.您知道在哪里可以找到实施了哪些路口的列表吗?还是不知道有什么新主意?

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没有无限的Line或Ray概念.因此,确实需要为此使用细分或线串.确实,使用Segment看起来是最好的方法,但是,交集()现在可能不支持它.如果非常需要,可以创建带有功能请求的故障单.现在,您可以使用Linestring而不是Segment来定义线.要存储结果,您可以使用MultiLinestring或Points向量.在第二种情况下,您将获得相交点,因此AFAIU正是您所需要的:

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);

如果以上内容未编译,则应使用最新版本的Boost.

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

您可能不应该创建包含double的最低/最高值的Linestring.这是因为您会收到大量的数字错误.段的点越近越好.例如,您可以手动计算线段与Polgon的边界框或边界球等的交集的线段的点.

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.

这篇关于相交线Poly Boost几何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆