本文整理汇总了Python中mathutils.Quaternion.normalized方法的典型用法代码示例。如果您正苦于以下问题:Python Quaternion.normalized方法的具体用法?Python Quaternion.normalized怎么用?Python Quaternion.normalized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathutils.Quaternion
的用法示例。
在下文中一共展示了Quaternion.normalized方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_LRS
# 需要导入模块: from mathutils import Quaternion [as 别名]
# 或者: from mathutils.Quaternion import normalized [as 别名]
def set_LRS(self, context, obj, LRS, rotation_mode='QUATERNION'):
L, R, S = LRS
L_mode, R_mode, S_mode, to_m, persp = self.calc_matrix(context, obj)
mL = (L is not None) and (L_mode != 'BASIS')
mR = (R is not None) and (R_mode != 'BASIS')
mS = (S is not None) and (S_mode != 'BASIS')
if mL or mR or mS:
in_m = matrix_inverted_safe(to_m) * BlUtil.Object.matrix_world(obj)
if not mL:
in_L = in_m.to_translation()
else:
L = Vector(L) # make sure it's a Vector
if L_mode in ('CAMERA', 'VIEW'):
L = Vector((L.x / persp.x, L.y / persp.y, -L.z)).lerp(
Vector((L.x * L.z / persp.x, L.y * L.z / persp.y, -L.z)), persp.z)
in_L = L
L = None
if not mR:
in_R = in_m.to_quaternion()
if not R: rotation_mode = obj.rotation_mode
else:
if rotation_mode == 'QUATERNION':
in_R = Quaternion(R)
elif rotation_mode == 'AXIS_ANGLE':
in_R = Quaternion(R[1:], R[0])
else:
if (len(R) == 4): R = R[1:]
in_R = Euler(R).to_quaternion()
R = None
if not mS:
in_S = in_m.to_scale()
else:
in_S = Vector(S)
S = None
x, y, z = in_R.normalized().to_matrix().col
in_m = matrix_compose(x*in_S.x, y*in_S.y, z*in_S.z, in_L)
BlUtil.Object.matrix_world_set(obj, to_m * in_m)
if (not mL) and (not L): L = Vector(obj.location)
if (not mR) and (not R): R = BlUtil.Object.rotation_convert(obj.rotation_mode, obj.rotation_quaternion,
obj.rotation_axis_angle, obj.rotation_euler, rotation_mode)
if (not mS) and (not S): S = Vector(obj.scale)
if L: obj.location = Vector(L)
if R: BlUtil.Object.rotation_apply(obj, R, rotation_mode)
if S: obj.scale = Vector(S)