Find the rotation angles of a triangle in 3D, given the coordinates of its vertices

我们两清 提交于 2019-12-03 21:11:59

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)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!