Find the rotation angles of a triangle in 3D, give

2019-04-01 19:18发布

I try to rotate and translate an equilateral triangle in 3D until his vertices reach some coordinates.

The vertices coordinates F,G,H and F',G',H' are known :

enter image description here

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

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...

I have to know by how much the triangle F'G'H' has to be rotated in degrees, around each axis (x,y,z), knowing that the rotations of the initial triangle are 0°.

By rotation for each axis, I'm talking about this:

enter image description here

Any ideas?

1条回答
戒情不戒烟
2楼-- · 2019-04-01 19:42

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)
查看更多
登录 后发表回答