def RBenVe(Object, Dir):
ObjectV = Object.normalized()
DirV = Dir.normalized()
cosTheta = ObjectV.dot(DirV)
rotationAxis = mathutils.Vector((0.0, 0.0, 0.0))
if (cosTheta < -1 + 0.001):
v = mathutils.Vector((0.0, 1.0, 0.0))
rotationAxis = ObjectV.cross(v)
rotationAxis = rotationAxis.normalized()
q = mathutils.Quaternion()
q.w = 0.0
q.x = rotationAxis.x
q.y = rotationAxis.y
q.z = rotationAxis.z
return q
rotationAxis = ObjectV.cross(DirV)
s = math.sqrt((1.0 + cosTheta) * 2.0)
invs = 1 / s
q = mathutils.Quaternion()
q.w = s * 0.5
q.x = rotationAxis.x * invs
q.y = rotationAxis.y * invs
q.z = rotationAxis.z * invs
return q
评论列表
文章目录