def rotation(self):
'''Extracts Euler angles of rotation from this matrix.
This attempts to find alternate rotations in case of gimbal lock,
but all of the usual problems with Euler angles apply here.
All Euler angles are in radians.
'''
(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) = self._v
rotY = D = math.asin(c)
C = math.cos(rotY)
if (abs(C) > 0.005):
trX = k/C ; trY = -g/C ; rotX = math.atan2(trY, trX)
trX = a/C ; trY = -b/C ; rotZ = math.atan2(trY, trX)
else:
rotX = 0
trX = f ; trY = e ; rotZ = math.atan2(trY, trX)
return V(rotX,rotY,rotZ)
评论列表
文章目录