本文整理汇总了Python中UM.Math.Quaternion.Quaternion.normalize方法的典型用法代码示例。如果您正苦于以下问题:Python Quaternion.normalize方法的具体用法?Python Quaternion.normalize怎么用?Python Quaternion.normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UM.Math.Quaternion.Quaternion
的用法示例。
在下文中一共展示了Quaternion.normalize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SceneNode
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import normalize [as 别名]
#.........这里部分代码省略.........
return deepcopy(self._world_transformation)
## \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)
## Get the local orientation value.
def getOrientation(self):
return deepcopy(self._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
if transform_space == SceneNode.TransformSpace.Local:
self._orientation = self._orientation * rotation
elif transform_space == SceneNode.TransformSpace.Parent:
self._orientation = rotation * self._orientation
elif transform_space == SceneNode.TransformSpace.World:
self._orientation = self._orientation * self._getDerivedOrientation().getInverse() * rotation * self._getDerivedOrientation()
else:
raise ValueError("Unknown transform space {0}".format(transform_space))
self._orientation.normalize()
self._transformChanged()
## Set the local orientation of this scene node.
#
# \param orientation \type{Quaternion} The new orientation of this scene node.
def setOrientation(self, orientation):
if not self._enabled or orientation == self._orientation:
return
self._orientation = orientation
self._orientation.normalize()
self._transformChanged()
## Get the local scaling value.
def getScale(self):
return deepcopy(self._scale)
## Scale the scene object (and thus its children) by given amount
#
# \param scale \type{Vector} A Vector with three scale values
# \param transform_space The space relative to which to scale. Can be any one of the constants in SceneNode::TransformSpace.
def scale(self, scale, transform_space = TransformSpace.Local):
if not self._enabled:
return
if transform_space == SceneNode.TransformSpace.Local:
self._scale = self._scale.scale(scale)
elif transform_space == SceneNode.TransformSpace.Parent:
raise NotImplementedError()
elif transform_space == SceneNode.TransformSpace.World:
if self._parent:
scale_change = Vector(1,1,1) - scale
示例2: SceneNode
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import normalize [as 别名]
#.........这里部分代码省略.........
return deepcopy(self._world_transformation)
## \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)
## Get the local orientation value.
def getOrientation(self):
return deepcopy(self._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
if transform_space == SceneNode.TransformSpace.Local:
self._orientation = self._orientation * rotation
elif transform_space == SceneNode.TransformSpace.Parent:
self._orientation = rotation * self._orientation
elif transform_space == SceneNode.TransformSpace.World:
self._orientation = self._orientation * self._getDerivedOrientation().getInverse() * rotation * self._getDerivedOrientation()
else:
raise ValueError("Unknown transform space {0}".format(transform_space))
self._orientation.normalize()
self._transformChanged()
## Set the local orientation of this scene node.
#
# \param orientation \type{Quaternion} The new orientation of this scene node.
def setOrientation(self, orientation):
if not self._enabled or orientation == self._orientation:
return
self._orientation = orientation
self._orientation.normalize()
self._transformChanged()
## Get the local scaling value.
def getScale(self):
return deepcopy(self._scale)
## Scale the scene object (and thus its children) by given amount
#
# \param scale \type{Vector} A Vector with three scale values
# \param transform_space The space relative to which to scale. Can be any one of the constants in SceneNode::TransformSpace.
def scale(self, scale, transform_space = TransformSpace.Local):
if not self._enabled:
return
if transform_space == SceneNode.TransformSpace.Local:
self._scale = self._scale.scale(scale)
elif transform_space == SceneNode.TransformSpace.Parent:
raise NotImplementedError()
elif transform_space == SceneNode.TransformSpace.World:
raise NotImplementedError()
else: