本文整理汇总了Python中mathutils.Vector.closs方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.closs方法的具体用法?Python Vector.closs怎么用?Python Vector.closs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathutils.Vector
的用法示例。
在下文中一共展示了Vector.closs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: viewrotate_apply
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import closs [as 别名]
def viewrotate_apply(self, context, event):
# FIXME
vod = self.vod
x, y = event.x, event.y
if context.user_preferences.inputs.view_rotate_method == 'TRACKBALL':
newvec = calctrackballvec(context.region, event.x, event.y)
dvec = newvec - vod.trackvec
angle = (dvec.length / (2.0 * TRACKBALLSIZE)) * math.pi
angle = angle_wrap_rad(angle)
axis = vod.trackvec.cross(newvec)
q1 = Quaternion(axis, angle)
vod.viewquat = q1 * vod.oldquat
self.viewrotate_apply_dyn_ofs(vod.viewquat)
else:
zvec_global = Vector([0, 0, 1])
sensitivity = 0.007
m = vod.viewquat.to_matrix()
m_inv = m.inverted()
if (zvec_global - m_inv.col[2]).length > 0.001:
xaxis = zvec_global.closs(m_inv.col[0])
if xaxis.dot(m_inv.col[0]) < 0:
xaxis.negate()
fac = zvec_global.angle(m_inv.col[2]) / math.pi
fac = abs(fac - 0.5) * 2
fac *= fac
xaxis = xaxis.lerp(m_inv.col[0], fac)
else:
xaxis = m_inv[0].copy()
quat_local_x = Quaternion(xaxis, sensitivity * - (y - vod.oldy))
quat_local_x = vod.viewquat * quat_local_x
def axis_angle_to_quat_single(axis, angle):
angle_half = angle * 0.5
angle_cos = math.cos(angle_half)
angle_sin = math.sin(angle_half)
axis_index = ['X', 'Y', 'Z'].index(axis)
q = Quaternion([angle_cos, 0, 0, 0])
q[axis_index + 1] = angle_sin
return q
quat_global_z = axis_angle_to_quat_single(
'Z', sensitivity * vod.reverse * (x - vod.oldx))
vod.viewquat = quat_local_x * quat_global_z
self.viewrotate_apply_dyn_ofs(vod.viewquat)
vod.viewquat.normalize()
context.region_data.view_rotation = vod.viewquat.inverted()
if vod.axis_snap:
self.viewrotate_apply_snap(vod)
vod.oldx = x
vod.oldy = y
ED_view3d_camera_lock_sync(vod.v3d, context.region_data)
context.region.tag_redraw()
pass