在 3D 空间中映射两个三角形之间的点
编辑
我不知道这是否重要,但目标三角形角度可能与源三角形角度不同。这个事实是否使变换变得非仿射? (我不确定)
我在 3D 空间中有两个三角形。鉴于我知道第一个三角形中点的 (x,y,z) 并且我知道向量 V1,V2,V3。我需要找到点(x',y',z')。我应该对带有向量 V1,V2,V3 的点 (x,y,z) 进行什么变换才能获得第二个三角形中的变换点?
感谢您的帮助!
EDIT
I don't know is it important, but destination triangle angles may be different than these of source. Does that fact makes transformation non-affine ? (i'm not sure)
I have two triangles in 3D space. Given that i know (x,y,z) of point in first triangle and i know vectors V1,V2,V3. I need to find point (x',y',z'). What transformation i should do to point (x,y,z) with vectors V1,V2,V3 to get that transformed point in the second triangle ?
Thanks for help !!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
简而言之,这比乍一看要复杂,并且您对问题施加的约束的性质需要一些比您想象的更先进的技术。
因此,作为解释,我将稍微更改一下您的符号。考虑 3 对向量(它们对应于问题中两个三角形的顶点):
通常,您的问题将通过识别以下形式的线性变换来解决:
这样:
需要这个公式,因为变换似乎是 3-D 仿射变换,而不是 3-D 线性变换。如果它是线性变换,则任何包含原点的三角形都必然映射到另一个包含原点的三角形。扩展到 4-D 空间允许使用 4-D 线性变换来执行 3-D 仿射变换。
也就是说,首先要注意的是这个问题是欠约束的(9 个方程,12 个未知数);没有唯一的解决方案。事实上有无限多个。然而,你的问题比这更受限制,所以还有一些希望。 您还有其他约束
给定向量查找,
(使用您的定义向量 a、b 和 < b>c)
虽然这对您的问题提出了额外的限制,但它将它从可以使用线性方法轻松解决的问题更改为需要 凸编程寻找独特的解决方案。
也就是说,这里有一些可能的方法:
更新:我对此进行了一些思考,并且发现了一种无需使用凸规划即可生成正确仿射变换的方法。可以通过为每个三角形生成第四个顶点来完成,称为
y
和y'
:其中
×
是两个向量的3-D叉积(即省略每个向量中最后的1;但记住将1附加到y 和 y' 一旦计算完毕)。从那里,您可以应用从列向量创建矩阵 M 和 M' 的标准技术:并使用 Steve Emmerson 建议的方法(在 4 维而不是 3 维中):
The short answer is that this is more complicated than it at first appears, and the nature of the constraints you are placing on the problem require some more advanced techniques than you might think.
So, by way of an explanation, I'm going to change your notation a bit. Consider 3 pairs of vectors (these correspond to your the vertices of the two triangles in your problem):
Ordinarily, your problem would be solved through the identification of the linear transformation of the form:
such that:
This formulation is needed because the transformation seems to be a 3-D affine transformation, not a 3-D linear transformation. If it were a linear transformation, any triangle containing the origin would necessarily map to another triangle containing the origin. Extending to a 4-D space allows 4-D linear transformation to be used to perform 3-D affine transformation.
That said, the first thing to notice is that this problem is underconstrained (9 equations with 12 unknowns); there is no unique solution. There are in fact infinitely many. However, your problem is somewhat more constrained than this, so there's some hope. You have the additional constraints given a vector
find
such that (using your definition vectors a, b, and c)
While this presents an additional constraint on your problem, it changes it from being one that could easily solved using linear methods to one that requires Convex Programming to find a unique solution.
That said, here are some possible aproaches:
UPDATE: I've given this some thought and I see a way to generate the correct affine transformation without using convex programming. It can be done by generating a fourth vertex for each of the triangles, called
y
andy'
:where
×
is the 3-D cross product of the two vectors (i.e. omit the final 1 in each vector; but remember to append the 1 onto y and y' once you have them calculated). From there, you can apply the standard technique of creating matrices M and M' from column vectors:and use the method Steve Emmerson suggested (in 4-D rather than 3-D):
我想您可能正在寻找重心坐标?
I think you might be looking for barycentric coordinates?
检查 andand 的理论评论
// Qt 代码
以及此代码的实际操作视频:
http://www.youtube.com/watch?v=yOU90pBoyZY
check andand's comments for theory
// Qt code
And a video of this code in action:
http://www.youtube.com/watch?v=yOU90pBoyZY
您需要一个矩阵变换 T,使得 TX = X',其中 X 是矩阵,其列是第一个三角形的顶点坐标,而 X' 与第二个三角形的顶点坐标相同。将每边乘以 X 的倒数得到 T = X' X-1。
You want a matrix transformation T such that T X = X', where X is the matrix whose columns are the co-ordinates of the vertexes of the first triangle and X' is the same for the second triangle. Multiplying each side by the inverse of X yields T = X' X-1.
只需将向量添加到每个点即可。点+向量==新点。这基本上与首先创建向量相反:V1 == (x1'-x1, y1'-y1, z1'-z1),所以 (x1', y1', z1') == (x1+ V1x、y1+v1y、z1+V1z)。
Simply add the vectors to each point. Point + Vector == new Point. This is basically the opposite of creating the Vector in the first place: V1 == (x1'-x1, y1'-y1, z1'-z1), so (x1', y1', z1') == (x1+V1x, y1+v1y, z1+V1z).
让
那么
x' = αx1' + βx2' + γx3'
所以
Let
Then
x' = αx1' + βx2' + γx3'
So