本文整理汇总了Python中UM.Math.Quaternion.Quaternion.getInverse方法的典型用法代码示例。如果您正苦于以下问题:Python Quaternion.getInverse方法的具体用法?Python Quaternion.getInverse怎么用?Python Quaternion.getInverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UM.Math.Quaternion.Quaternion
的用法示例。
在下文中一共展示了Quaternion.getInverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SceneNode
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import getInverse [as 别名]
#.........这里部分代码省略.........
## \brief Returns the local transformation with respect to its parent. (from parent to local)
# \retuns transformation 4x4 (homogenous) matrix
def getLocalTransformation(self) -> Matrix:
if self._transformation is None:
self._updateTransformation()
return deepcopy(self._transformation)
def setTransformation(self, transformation: Matrix):
self._transformation = deepcopy(transformation) # Make a copy to ensure we never change the given transformation
self._transformChanged()
## Get the local orientation value.
def getOrientation(self) -> Quaternion:
return deepcopy(self._orientation)
def getWorldOrientation(self) -> Quaternion:
return deepcopy(self._derived_orientation)
## \brief Rotate the scene object (and thus its children) by given amount
#
# \param rotation \type{Quaternion} A quaternion indicating the amount of rotation.
# \param transform_space The space relative to which to rotate. Can be any one of the constants in SceneNode::TransformSpace.
def rotate(self, rotation: Quaternion, transform_space: int = TransformSpace.Local):
if not self._enabled:
return
orientation_matrix = rotation.toMatrix()
if transform_space == SceneNode.TransformSpace.Local:
self._transformation.multiply(orientation_matrix)
elif transform_space == SceneNode.TransformSpace.Parent:
self._transformation.preMultiply(orientation_matrix)
elif transform_space == SceneNode.TransformSpace.World:
self._transformation.multiply(self._world_transformation.getInverse())
self._transformation.multiply(orientation_matrix)
self._transformation.multiply(self._world_transformation)
self._transformChanged()
## Set the local orientation of this scene node.
#
# \param orientation \type{Quaternion} The new orientation of this scene node.
# \param transform_space The space relative to which to rotate. Can be Local or World from SceneNode::TransformSpace.
def setOrientation(self, orientation: Quaternion, transform_space: int = TransformSpace.Local):
if not self._enabled or orientation == self._orientation:
return
new_transform_matrix = Matrix()
if transform_space == SceneNode.TransformSpace.World:
if self.getWorldOrientation() == orientation:
return
new_orientation = orientation * (self.getWorldOrientation() * self._orientation.getInverse()).getInverse()
orientation_matrix = new_orientation.toMatrix()
else: # Local
orientation_matrix = orientation.toMatrix()
euler_angles = orientation_matrix.getEuler()
new_transform_matrix.compose(scale = self._scale, angles = euler_angles, translate = self._position, shear = self._shear)
self._transformation = new_transform_matrix
self._transformChanged()
## Get the local scaling value.
def getScale(self) -> Vector:
return self._scale
示例2: SceneNode
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import getInverse [as 别名]
#.........这里部分代码省略.........
## \brief Returns the local transformation with respect to its parent. (from parent to local)
# \retuns transformation 4x4 (homogenous) matrix
def getLocalTransformation(self):
if self._transformation is None:
self._updateTransformation()
return deepcopy(self._transformation)
def setTransformation(self, transformation):
self._transformation = transformation
self._transformChanged()
## Get the local orientation value.
def getOrientation(self):
return deepcopy(self._orientation)
def getWorldOrientation(self):
return deepcopy(self._derived_orientation)
## \brief Rotate the scene object (and thus its children) by given amount
#
# \param rotation \type{Quaternion} A quaternion indicating the amount of rotation.
# \param transform_space The space relative to which to rotate. Can be any one of the constants in SceneNode::TransformSpace.
def rotate(self, rotation, transform_space = TransformSpace.Local):
if not self._enabled:
return
orientation_matrix = rotation.toMatrix()
if transform_space == SceneNode.TransformSpace.Local:
self._transformation.multiply(orientation_matrix)
elif transform_space == SceneNode.TransformSpace.Parent:
self._transformation.preMultiply(orientation_matrix)
elif transform_space == SceneNode.TransformSpace.World:
self._transformation.multiply(self._world_transformation.getInverse())
self._transformation.multiply(orientation_matrix)
self._transformation.multiply(self._world_transformation)
self._transformChanged()
## Set the local orientation of this scene node.
#
# \param orientation \type{Quaternion} The new orientation of this scene node.
# \param transform_space The space relative to which to rotate. Can be Local or World from SceneNode::TransformSpace.
def setOrientation(self, orientation, transform_space = TransformSpace.Local):
if not self._enabled or orientation == self._orientation:
return
new_transform_matrix = Matrix()
if transform_space == SceneNode.TransformSpace.Local:
orientation_matrix = orientation.toMatrix()
if transform_space == SceneNode.TransformSpace.World:
if self.getWorldOrientation() == orientation:
return
new_orientation = orientation * (self.getWorldOrientation() * self._orientation.getInverse()).getInverse()
orientation_matrix = new_orientation.toMatrix()
euler_angles = orientation_matrix.getEuler()
new_transform_matrix.compose(scale = self._scale, angles = euler_angles, translate = self._position, shear = self._shear)
self._transformation = new_transform_matrix
self._transformChanged()
## Get the local scaling value.
def getScale(self):
return deepcopy(self._scale)
def getWorldScale(self):