本文整理汇总了Python中UM.Math.Quaternion.Quaternion.toMatrix方法的典型用法代码示例。如果您正苦于以下问题:Python Quaternion.toMatrix方法的具体用法?Python Quaternion.toMatrix怎么用?Python Quaternion.toMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UM.Math.Quaternion.Quaternion
的用法示例。
在下文中一共展示了Quaternion.toMatrix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_toMatrix
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import toMatrix [as 别名]
def test_toMatrix(self):
q1 = Quaternion()
q1.setByAngleAxis(math.pi / 2, Vector.Unit_Z)
m1 = q1.toMatrix()
m2 = Matrix()
m2.setByRotationAxis(math.pi / 2, Vector.Unit_Z)
self.assertTrue(Float.fuzzyCompare(m1.at(0, 0), m2.at(0, 0), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(0, 1), m2.at(0, 1), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(0, 2), m2.at(0, 2), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(0, 3), m2.at(0, 3), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(1, 0), m2.at(1, 0), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(1, 1), m2.at(1, 1), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(1, 2), m2.at(1, 2), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(1, 3), m2.at(1, 3), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(2, 0), m2.at(2, 0), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(2, 1), m2.at(2, 1), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(2, 2), m2.at(2, 2), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(2, 3), m2.at(2, 3), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(3, 0), m2.at(3, 0), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(3, 1), m2.at(3, 1), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(3, 2), m2.at(3, 2), 1e-6))
self.assertTrue(Float.fuzzyCompare(m1.at(3, 3), m2.at(3, 3), 1e-6))
示例2: rotate
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import toMatrix [as 别名]
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()
示例3: setOrientation
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import toMatrix [as 别名]
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()