如何获取由平面描述的多边形的顶点

发布于 2024-09-24 15:01:11 字数 901 浏览 2 评论 0原文

这是一个没有得到解答的问题的重新发布,

基本上我正在尝试对具有以下格式的地图进行建模:

每个画笔定义一个实体区域。画笔将该区域定义为四个或更多平面的交集。每个平面由三个非共线点定义。这些点必须按顺时针方向排列:

1--2----------------->
|
3
|
|
|
|
|
,

每个画笔语句如下所示:

 {
  ( 128 0 0 ) ( 128 1 0 ) ( 128 0 1 ) //plane 1
  ( 256 0 0 ) ( 256 0 1 ) ( 256 1 0 ) //plane 2
  ( 0 128 0 ) ( 0 128 1 ) ( 1 128 0 ) //plane 3
  ( 0 384 0 ) ( 1 384 0 ) ( 0 384 1 ) //plane 4
  ( 0 0 64 ) ( 1 0 64 ) ( 0 1 64 ) //plane 5
  ( 0 0 128 ) ( 0 1 128 ) ( 1 0 128 )//plane 6
 }

当您第一次看到它时,可能会有点困惑。它定义了一个从 (128,128,64) 延伸到 (256,384,128) 的矩形区域。单线的含义如下:

  ( 128 0 0 ) ( 128 1 0 ) ( 128 0 1 ) 
   1st Point   2nd Point   3rd Point 

我需要找到平面的交点,这样我就可以仅使用可以在 3d 空间中绘制 2d 面板的方法来绘制形状。 例如,以下代码将在空间中绘制一个三角形:

beginShape();
vertex(x0,y0,z0);
vertex(x1,y1,z1);
vertex(x2,y2,z2);
vertex(x0,y0,z0);
endShape();

是否有比循环遍历所有可能的平面相交更好的方法来计算顶点?

This is a repost of a question that went unanswered

basically I am trying to model a map that has the following format:

Each brush defines a solid region. Brushes define this region as the intersection of four or more planes. Each plane is defined by three noncolinear points. These points must go in a clockwise orientation:

1--2----------------->
|
3
|
|
|
|
|
,

Each brush statement looks like this:

 {
  ( 128 0 0 ) ( 128 1 0 ) ( 128 0 1 ) //plane 1
  ( 256 0 0 ) ( 256 0 1 ) ( 256 1 0 ) //plane 2
  ( 0 128 0 ) ( 0 128 1 ) ( 1 128 0 ) //plane 3
  ( 0 384 0 ) ( 1 384 0 ) ( 0 384 1 ) //plane 4
  ( 0 0 64 ) ( 1 0 64 ) ( 0 1 64 ) //plane 5
  ( 0 0 128 ) ( 0 1 128 ) ( 1 0 128 )//plane 6
 }

That's probably just a bit confusing when you first see it. It defines a rectangular region that extends from (128,128,64) to (256,384,128). Here's what a single line means:

  ( 128 0 0 ) ( 128 1 0 ) ( 128 0 1 ) 
   1st Point   2nd Point   3rd Point 

I need to find the intersection points of the planes so I can draw the shape only using a method that can draw 2d panels in 3d space.
The following code would draw a triangle in space for example:

beginShape();
vertex(x0,y0,z0);
vertex(x1,y1,z1);
vertex(x2,y2,z2);
vertex(x0,y0,z0);
endShape();

Is there a better way to calculate the vertices than to loop through all possibilities of plane interesctions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉殇 2024-10-01 15:01:11

我认为没有其他选择:关于顶点的唯一信息包含在平面中,从平面获取顶点的唯一方法是确定它们的交点,因此您必须循环遍历的可能性。

首先:

如果您确定这些平面确实限制了一个体积,并且没有一个平面是平行的,那么 3 个相邻平面的每种组合都应该产生一个顶点(只需同时求解平面方程适用于所有 3)。您可以很容易地消除体积之外的顶点(要成为形状的一部分,它们必须位于所有平面上或“后面”),因此如果您没有这种“邻接”,您可以只测试 3 个平面的每个组合信息并丢弃外部点。

让我惊讶的是,使用这种方法你只会有 卷 - 所以你可能可以这样做所有这些顶点上的 3d 凸包 以获得面的可绘制三角形。

I don't think there is any other option: the only information you have about the vertices is contained in the planes, and the only way to get the vertices from the planes is to determine their intersections, so you will have to loop through the possibilities.

To start:

If you are sure the planes do indeed bound a volume, and that none of the planes are parallel, then each combination of 3 adjascent planes should yield one vertex (just by simultaneously solving the plane equation for all 3). You can eliminate vertices outside your volume pretty easily (to be part of the shape, they must be on or 'behind' all of the planes) so you could just test every combination of 3, if you don't have this 'adjacency' information and discard the external points.

It strikes me that you will only have convex volumes using this method - so you can probably just do a 3d convex hull on all those vertices to get drawable triangles for the faces.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文