求向量在二十面体或其展开表面上的投影
考虑一个中心位于坐标原点的球体和一个内切二十面体,其方向使得两个最远的顶点位于 Z 坐标轴上,并且从任何顶点出现的边之一位于 XZ 平面中。
考虑一个源自球体中心的给定向量x
。由该向量给出的方向在某个点穿过二十面体的表面。
有没有一种优雅的方法来找到穿孔的面(考虑到所有的面都被枚举),然后找到这个面上的穿孔点?此任务需要将刺穿点投影到平坦的展开(展开)二十面体表面。
Consider a sphere with center in coordinates' origin, and an inscribed icosahedron, oriented such that the two most distant vertices lay on Z coordinate axis, and one of the edges emerging from any of that vertices lays in XZ plane.
Consider a given vector x
originating in the center of the sphere. Direction, given by this vector, pierce the surface of the icosahedron in a certain point.
Is there an elegant way to find the pierced facet (considering all the facets are enumerated), and then find the piercing point on this facet? This task is needed to project the pierce point to the flat unfolded (unwrapped) icosahedron surface.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该解决方案特定于您的应用程序,其中矢量从原点发出,二十面体以原点为中心。
使用二十面体的 12 个顶点定义 20 个三角形。对 3 进行排序,以便从二十面体外部观察时它们按逆时针顺序排列。因此,对于每个三角形,您都会有一个包含 3 个顶点的列表。对于每个三角形,构造一个 3x3 矩阵,其中列是三角形的顶点:
您需要该矩阵的逆矩阵(用您选择的语言搜索 SO 或 google 查找快速 3x3 逆矩阵)。
现在,对于每个向量,您希望将其乘以所有 20 个矩阵。因此,对于每个三角形,计算:
B = V*T(inverse)
如果 B 的所有 3 个元素均为正(负?),则这就是相交三角形。
接下来,标准化 B - 将其除以它的长度,使其具有单位长度。这将使 B 成为该三角形上交点的重心坐标。您还可以通过将重心坐标乘以原始点矩阵来计算实际交点 I:
I = B*T
这也适用于查找展开三角形上交点的 2D 坐标。因此,使用 2D 坐标的 2x3 矩阵代替 T。
最后一个优化。如果将每个三角形的 3 个顶点相加,就会得到该三角形的法向量。如果计算向量与每条法线的点积,则具有最大点积的三角形将是相交的三角形。这一事实特定于以原点为中心且所讨论的射线从原点发出的正多面体。这比通过整个矩阵相乘来确定哪个矩阵被击中要快。您仍然需要进行 1 次矩阵乘法才能找到重心坐标。
您还可以搜索射线-三角形相交并阅读有关重心坐标的信息,但这些解决方案将比这个特定问题所需的更通用。
This solution is specific to your application where the vectors emanate from the origin and the icosahedron is centered at the origin.
Define 20 triangles using the 12 verticies of the icosahedron. Order the 3 so that they are in counterclockwise order when viewed from outside the icosahedron. So for each triangle you'll have a list of 3 verticies. For each triangle construct a 3x3 matrix where the columns are the verticies of the triangle:
You'll need the inverse of this matrix (search SO or google for a fast 3x3 inverse in the language of your choice).
Now for each vector, you want to multiply it by all 20 matricies. So for each triangle compute:
B = V*T(inverse)
If all 3 elements of B are positive (negative?) this is the intersected triangle.
Next, normalize B - divide it by its length so it has unit length. This will make B the Barycentric coordinates of the intersection point on that triangle. You can also compute the actual intersection point I by multiplying the Barycentric coordinates by the original point matrix:
I = B*T
This also works for finding the 2D coordinates of the intersection point on the unfolded triangle. So use the 2x3 matrix of 2D coordinates instead of T.
One last optimization. If you sum the 3 verticies of each triangle this will give you a normal vector for that triangle. If you compute the dot product of your vector with each of the normals, the triangle with the largest dot product will be the one intersected. This fact is specific to regular polyhedrons centered at the origin with the rays in question emanating from the origin. This is faster than doing the whole matrix multiply to determine which one is hit. You'll still need to do 1 matrix multiply to find the Barycentric coordinates.
You can also search for ray-triangle intersection and read about Barycentric coordinates, but those solutions will be more generalized than this specific problem requires.
好吧,这不是我的领域,但没有人回答,所以我会尝试一下。您可以将二十面体表示为 12 个顶点 - 10 个赤道顶点,加上顶部和底部(它们本质上没有赤道性,这只是我们的坐标系对其进行分类的一种方法)。
这些顶点又可以表示为线段 - 一端是原点,另一端是顶点。鉴于此,您可以得出赤道以上的海拔高度。如果您知道矢量的高度(同样是在赤道上方),您可以确定该矢量与二十面体的三个部分中的哪一个相交 - 北面、南面或赤道面。
根据您的矢量,您还可以确定方位角。如果您有从顶点向量分别导出的方位角和高度,那么计算一组两个面(因此有四个顶点)是相当简单的。计算每个顶点段给定向量之间的角距将告诉您它位于两个面中的哪一个 - 具有两个轴承总和中较小者的面将是该面。
这就是我陷入困境的地方......我看不到一种简单的方法来确定与脸部的交点。希望这至少对第一部分有帮助。
Okay, this isn't really my field, but nobody else has answered, so I'll take a stab at it. you can represent an icosahedron as 12 vertices - 10 equatorial vertices, plus top and bottom (nothing inherently equatorial about them, this is just a way of classifying it for our coordinate system).
Those vertices, in turn, can be represented as segments - one end is the origin, the other the vertex. Given that, you can derive the altitude above the equator. If you know the altitude of the vector (again, above the equator), you can determine which of the three sections of the icosahedron the vector is intersecting - the northern, southern, or equatorial set.
From your vector, you can also determine azimuth. If you have the respective derived azimuths and altitudes from the vertex vectors, it's a fairly simple calculation a set of two faces (and thus four vertices). Computing the angular separation between the given vector each vertex segment will tell you which of the two faces it is on - face with the smaller of the two sums of bearings will be that face.
That's where I'm stuck...I can't see a simple way to determine the point of intersection with the face. Hopefully this will be helpful for the first part, at least.