给定顶点坐标,在 3D 中找到三角形的旋转角度 [英] Find the rotation angles of a triangle in 3D, given the coordinates of its vertices
问题描述
我尝试在 3D 中旋转和平移一个等边三角形,直到他的顶点到达某个坐标.
I try to rotate and translate an equilateral triangle in 3D until his vertices reach some coordinates.
顶点坐标 F,G,H 和 F',G',H' 是已知的:
The vertices coordinates F,G,H and F',G',H' are known :
我能够像这样找到新的质心 c'
坐标:
I was able to find the new centroid c'
coordinates like this :
c'.x = ( F'.x + G'.x + H'.x ) / 3
c'.y = ( F'.y + G'.y + H'.y ) / 3
c'.z = ( F'.z + G'.z + H'.z ) / 3
所以翻译三角形没问题.但我找不到一种方法来计算将 F'G'H' 三角形放在正确位置所需的旋转......
So no problem to translate the triangle. But I can't find a way to calculate the rotations needed to put F'G'H' triangle in the right position...
我必须知道三角形 F'G'H' 必须围绕每个轴 (x,y,z) 旋转多少度,知道初始三角形的旋转为 0°.
通过每个轴的旋转,我在谈论这个:
By rotation for each axis, I'm talking about this:
有什么想法吗?
推荐答案
技巧是使用叉积 b4 和旋转后找到三角形的法向量
trick is to find the normal vectors of the triangles using cross product b4 and after rotations
v1 = (F.x - G.x, F.y - G.y, F.z - G.z)
v2 = (F.x - H.x, F.y - H.y, F.z - H.z)
n = cross_prod(v1, v2) # see http://en.wikipedia.org/wiki/Cross_product
n = n / norm(n) # normalize to unit vector
v'1 = (F'.x - G'.x, F'.y - G'.y, F'.z - G'.z)
v'2 = (F'.x - H'.x, F'.y - H'.y, F'.z - H'.z)
n' = cross_prod(v'1, v'2)
n' = n' / norm(n')
rot = arc_cos(n.x * n'.x + n.y * n'.y + n.z * n'.z)
这篇关于给定顶点坐标,在 3D 中找到三角形的旋转角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!