如何获得 4D 网格的 3D 横截面? [英] How do I get a 3D cross section of a 4D mesh?

查看:16
本文介绍了如何获得 4D 网格的 3D 横截面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 polychoron 表示为一个四维网格,与面部一起存储-顶点法.所有的面都是三角形.怎样才能得到图形的三维横截面?

I have a polychoron represented as a four-dimensional mesh, stored with the face-vertex method. All the faces are triangles. How can I get a three-dimensional cross-section of the figure?

我发现的最接近的是这个问题,但它是一维短的.

The closest thing I've found is this question, but it's one dimension short.

推荐答案

使用 4 个维度有点困难.

Working with 4 dimensions are a bit difficult.

解决问题的唯一方法是找到维度类比.

The only way to solve the problem is finding dimensional analogies.

让我们从二维开始

凸二维多边形具有凸一维边:线段.

A convex 2D polygon has convex 1D sides: line segments.

填充的凸多边形的横截面是一条线段.

The cross-section of a filled convex polygon is a line segment.

计算你的 poligons 边缘与相交线的交点,你会得到一个凸多边形的两个交点,横截面将是一条线段.

Calculate the intersection points of your poligons edges with the intersecting line, you'll get two intersections for a convex polygon, and the cross section will be a line segment.

为此,您可以轻松地转换坐标,以便在坐标系的 Y 轴上做横截面.边的两点是A和B,它们的坐标是a1,a2和b1,b2.

To do this easily transform the coordinates so you do the cross section on the Y axis of the coordinate system. The two points of the edge is A and B. Their coordinates are a1, a2 and b1, b2.

如果 a1 和 b1 的符号相同,(又名 a1*b1 > 0)边不会与 Y 轴相交.

If the signs of a1 and b1 is the same, (aka a1*b1 > 0) the edge won't intersect the Y axis.

否则计算 k = a1/(a1-b1).

Otherwise calculate k = a1/(a1-b1).

那么交点的坐标就是:(0; (1-k)*a2+k*b2)

Then the coordinate of the intersection point will be: (0; (1-k)*a2+k*b2)

正如我所说的凸多边形,你会得到两个交点,连接这两个点以获得一维横截面.

As I said for convex polygons you'll get two intersection points, connect the two point to get the 1D cross section.

现在让我们推广到 3D

凸面 3D 网格具有凸面 2D 边:三角形.

A convex 3D mesh has convex 2D sides: triangles.

再次,变换坐标以使操作更容易.让我们在 Y-Z 平面上获取网格的横截面,因此 X 坐标将再次为零.

Again, transform the coordinates to make the operation easier. Let's get the cross section of the mesh on the Y-Z plane, so the X coordinates will be zero again.

获取三角形的横截面.对它们的每个边缘使用上面的算法.由于我们有 3 个维度,边缘的端点将具有坐标 a1、a2、a3 和 b1、b2、b3.如果 a1*b1<0 我们有一个交点.所以

Get the cross sections of the triangles. Using the algorithm above for each edge of them. Since we have 3 dimensions the endpoints of the edge will have the coordinates a1, a2, a3 and b1, b2, b3. If a1*b1<0 we have an intersection point. So

设 k = a1/(a1 - b1)

Let k = a1 / (a1 - b1)

交点坐标为(0; (1-k)*a2+k*b2; (1-k)*a3+k*b3).存储这个坐标,还要存储网格的 A 点和 B 点的索引(边缘索引).以后会有用的.

The coordinate of the intersection point is (0; (1-k)*a2+k*b2; (1-k)*a3+k*b3). Store this coordinate, but also store the index of A and B points of the mesh (the edge index). It'll be useful later.

对于每个三角形,这将产生一条线段.

For each triangle this will yield a line segment.

现在您需要将这些横截面线段连接到一个多边形.这就是我们将边缘索引与交点一起存储的原因.您有一组线,您可以通过存储的边缘索引匹配它们的端点,因此您可以将它们连接成一个多边形.

Now you'll need to connect these cross section line segments to a polygon. That's why we stored the edge indexes along with the intersection points. You have a set of lines and you can match their endpoints by the stored edge index, so you can connect them into a polygon.

现在让我们推广到 4D

凸形 4D 网格具有凸形 3D边":四面体.(请注意您的面顶点表示可能不正确)

A convex 4D mesh has convex 3D "sides": tetrahedrons. (note probably your face-vertex representation is incorrect)

再次,变换坐标以使操作更容易.让我们在 Y-Z-W 超平面上获取网格的横截面,因此 X 坐标将再次为零.

Again, transform the coordinates to make the operation easier. Let's get the cross section of the mesh on the Y-Z-W hyperplane, so the X coordinates will be zero again.

获取四面体的横截面.对它们的每个面使用上面的算法.由于我们有 4 个维度,边缘的端点将具有坐标 a1、a2、a3、a4 和 b1、b2、b3、b4.如果 a1*b1<0 我们有一个交点.所以

Get the cross sections of the tetrahedrons. Using the algorithm above for each face of them. Since we have 4 dimensions the endpoints of the edge will have the coordinates a1, a2, a3, a4 and b1, b2, b3, b4. If a1*b1<0 we have an intersection point. So

设 k = a1/(a1 - b1)

Let k = a1 / (a1 - b1)

交点坐标为(0; (1-k)*a2+k*b2; (1-k)*a3+k*b3; (1-k)*a4+k*b4).

The coordinate of the intersection point is (0; (1-k)*a2+k*b2; (1-k)*a3+k*b3; (1-k)*a4+k*b4).

对于四面体的每个三角形,这将产生一条线段.对于每个四面体,这将产生一个三角形.对于这些三角形的每条边,还存储线段起源的 3D 网格的三角形的 A、B 和 C 点的索引(面索引).以后会有用的.

For each triangle of a tetrahedron this will yield a line segment. For each tetrahedron this will yield a triangle. For each edge of these triangles also store the index of A, B and C points of the triangle of the 3D mesh (the face index) the line segment originates from. It'll be useful later.

现在您需要将这些横截面三角形连接到 3D 网格.这就是我们将面部索引与相交边缘一起存储的原因.您有一组三角形,您可以通过存储的面索引匹配它们的边缘,因此您可以将它们连接成三角形网格.

Now you'll need to connect these cross section triangles to a 3D mesh. That's why we stored the face indexes along with the intersection edges. You have a set of triangles and you can match their edges by the stored face index, so you can connect them into a triangle mesh.

对于凹面 4D 网格,您可能有多个 3D 网格.

For concave 4D meshes you may have get multiple 3D meshes.

希望你能看到这个类比.

Hope you see the analogy.

具体实现会有点困难,您需要处理所有极端情况(除以零情况、浮点错误等).

The concrete implementation will be a bit diffcult, you'll need to take care of all corner cases (division by zero cases, floating point errors, etc).

这篇关于如何获得 4D 网格的 3D 横截面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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