多边形裁剪:仅“可见”区域
在下图中,您可以在 (1) 中看到一个三角形和一个圆形。给定该三角形中的专用点 X,我希望剪掉从该点看不到的所有内容。使用(2)中的简单多边形差分算法仅删除圆是没有问题的。但是我可以使用什么样的算法来获得像 (3) 中那样的多边形?
多边形总是简单的。
编辑:圆圈只是一个例子。每个简单的多边形都应该是可能的。
您可以通过查看游戏“盟军敢死队 - 敌后”的图像来想象我的需求:
In the image below you see in (1) a triangle and a circle. Given a dedicated point X in that triangle I want clip away everything that is not visible from this point. There's no problem with removing just the circle with a simple polygon difference algorithm like in (2). But what kind of algorithm can I use to get a polygon like in (3) ?
The Polygon is always simple.
Edit: The circle is just an example. Every simple polygon should be possible.
You can image my needs by taking a look at the image of the game "Commandos - Behind enemy lines":
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是基本思想。
我假设一个更一般的问题,但是将其适应您的问题会容易得多:给定一个包含所有形状、一个点和一组几何图形的
计划
形状,我们希望从平面图中删除从该点看不到的区域。我们想要做的是,对于每个形状,它的
starting_pold
和ending_polar
点,即属于该形状的具有最小和最大极角的 2 个点。现在,我们将从
plan
中删除形状,并删除由以下点形成的四边形
:starting_polar
、ending_polar< /code>,以及 2 条直线
(x,starting_极点)
和(x,ending_极点)
与规划
边界之间的交点。在您的情况下,计划将只是
三角形
。This is the basic idea.
I'm assuming a problem a few more general, but it will be a lot easier to adapt it to your problem: given a
plan
containing all the shapes, a point and a set of geometrical shapes, we want to remove from the plan the area not visible from that point.What we want to do is to get, for each shape, it's
starting_polar
andending_polar
points, that are the 2 points with the minimum and maximum polar angle belonging to the shape.Now we'll remove from the
plan
the shape and we'll remove thequadrilateral
formed by the points:starting_polar
,ending_polar
, and the intersections between the 2 straight lines(x, starting_polar)
and(x, ending_polar)
and the boundaries of theplan
.In your case the plan will simply be the
triangle
.C平行于D,G平行于A,B平行于F,D为直径。
C parallel to D, G parallel to A, B parallel to F, D is diameter.