本文整理汇总了Python中UM.Math.Vector.Vector.dot方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.dot方法的具体用法?Python Vector.dot怎么用?Python Vector.dot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UM.Math.Vector.Vector
的用法示例。
在下文中一共展示了Vector.dot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _rotateCamera
# 需要导入模块: from UM.Math.Vector import Vector [as 别名]
# 或者: from UM.Math.Vector.Vector import dot [as 别名]
def _rotateCamera(self, x, y):
camera = self._scene.getActiveCamera()
if not camera or not camera.isEnabled():
return
self._scene.acquireLock()
dx = math.radians(x * 180.0)
dy = math.radians(y * 180.0)
diff = camera.getPosition() - self._origin
diff_flat = Vector(diff.x, 0.0, diff.z).getNormalized()
try:
new_angle = math.acos(diff_flat.dot(diff.getNormalized())) + dy
except ValueError:
return
m = Matrix()
m.setByRotationAxis(dx, Vector.Unit_Y)
if new_angle < (math.pi / 2 - 0.01):
m.rotateByAxis(dy, Vector.Unit_Y.cross(diff).normalize())
n = diff.multiply(m)
n += self._origin
camera.setPosition(n)
camera.lookAt(self._origin)
self._scene.releaseLock()
示例2: __imul__
# 需要导入模块: from UM.Math.Vector import Vector [as 别名]
# 或者: from UM.Math.Vector.Vector import dot [as 别名]
def __imul__(self, other):
if type(other) is Quaternion:
v1 = Vector(other.x, other.y, other.z)
v2 = Vector(self.x, self.y, self.z)
w = other.w * self.w - v1.dot(v2)
v = v2 * other.w + v1 * self.w + v2.cross(v1)
self._data[0] = v.x
self._data[1] = v.y
self._data[2] = v.z
self._data[3] = w
elif type(other) is float or type(other) is int:
self._data *= other
else:
raise NotImplementedError()
return self