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

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

问题描述

我有一个以四维网格表示的 polychoron ,顶点法。所有的面都是三角形。我怎样才能得到这个图的三维横截面?



我发现的最接近的东西是这个问题,但它是一维短小的。

解决方案

使用4个维度有点困难。

解决这个问题的唯一方法是找到尺寸类比。



我们从2D开始



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



填充的凸多边形的横截面是线段。



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



为了做到这一点很容易转换坐标,以便在坐标系的Y轴上执行横截面。边的两点是A和B.它们的坐标是a1,a2和b1,b2。



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

否则计算k = a1 /(a1-b1)。然后交点坐标为:(0;(1-k)* a2 + k * b2)


$ b

正如我所说的凸多边形,您将获得两个交点,将两个点连接以获得一维横截面。



现在让我们推广到3D



一个凸3D网格具有凸二维边:三角形。

转换坐标以使操作更容易。让我们在Y-Z平面上得到网格的横截面,所以X坐标将再次为零。



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

让k = a1 /(a1 - b1)

交点的坐标是(0 ;(1-k)* a2 + k * b2;(1-k)* a3 + k * b3)。存储该坐标,同时存储网格的A和B点的索引(边缘索引)。稍后会有用。



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

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



现在让我们推广到4D



凸4D网格具有凸3D边:四面体。 (注意你的脸部顶点表示是不正确的)

再次,转换坐标以使操作更容易。我们来看Y-Z-W超平面上网格的横截面,所以X坐标将再次为零。



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

让k = a1 /(a1 - b1)

交点的坐标是(0 ;(1-k)* a2 + k * b2;(1-k)* a3 + k * b3;(1-k)* a4 + k * b4)。

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



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



对于凹形4D网格,您可能有获得多个3D网格。






希望你能看到类比。

具体的实现会有点困难,你需要关心所有的角落情况(除以零情况,浮点错误等)。

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.

解决方案

Working with 4 dimensions are a bit difficult.

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

Let's start from 2D

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

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

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.

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.

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

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

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.

Now let's generalize to 3D

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

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.

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

Let k = a1 / (a1 - b1)

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.

Now let's generalize to 4D

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

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.

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

Let k = a1 / (a1 - b1)

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

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.

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.

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天全站免登陆