本文整理汇总了Python中UM.Math.Quaternion.Quaternion.setByAngleAxis方法的典型用法代码示例。如果您正苦于以下问题:Python Quaternion.setByAngleAxis方法的具体用法?Python Quaternion.setByAngleAxis怎么用?Python Quaternion.setByAngleAxis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UM.Math.Quaternion.Quaternion
的用法示例。
在下文中一共展示了Quaternion.setByAngleAxis方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_toMatrix
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import setByAngleAxis [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: test_setByAxis
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import setByAngleAxis [as 别名]
def test_setByAxis(self):
q = Quaternion()
q.setByAngleAxis(math.pi / 2, Vector.Unit_Z)
self.assertEqual(q.x, 0.0)
self.assertEqual(q.y, 0.0)
self.assertTrue(Float.fuzzyCompare(q.z, math.sqrt(2.0) / 2.0, 1e-6))
self.assertTrue(Float.fuzzyCompare(q.w, math.sqrt(2.0) / 2.0, 1e-6))
示例3: test_rotateVector
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import setByAngleAxis [as 别名]
def test_rotateVector(self):
q1 = Quaternion()
q1.setByAngleAxis(math.pi / 2, Vector.Unit_Z)
v = Vector(0, 1, 0)
v = q1.rotate(v)
self.assertTrue(Float.fuzzyCompare(v.x, -1.0, 1e-6))
self.assertTrue(Float.fuzzyCompare(v.y, 0.0, 1e-6))
self.assertTrue(Float.fuzzyCompare(v.z, 0.0, 1e-6))
示例4: test_invert
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import setByAngleAxis [as 别名]
def test_invert(self):
q1 = Quaternion()
q1.setByAngleAxis(math.pi, Vector.Unit_Z)
q1.invert()
q2 = Quaternion()
q2.setByAngleAxis(math.pi, -Vector.Unit_Z)
self.assertEqual(q1, q2)
示例5: test_fromMatrix
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import setByAngleAxis [as 别名]
def test_fromMatrix(self):
m = Matrix()
m.setByRotationAxis(math.pi / 2, Vector.Unit_Z)
q1 = Quaternion.fromMatrix(m)
q2 = Quaternion()
q2.setByAngleAxis(math.pi / 2, Vector.Unit_Z)
self.assertTrue(Float.fuzzyCompare(q1.x, q2.x, 1e-6))
self.assertTrue(Float.fuzzyCompare(q1.y, q2.y, 1e-6))
self.assertTrue(Float.fuzzyCompare(q1.z, q2.z, 1e-6))
self.assertTrue(Float.fuzzyCompare(q1.w, q2.w, 1e-6))
示例6: test_slerp
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import setByAngleAxis [as 别名]
def test_slerp(self):
q1 = Quaternion()
q1.setByAngleAxis(0, Vector.Unit_Z)
q2 = Quaternion()
q2.setByAngleAxis(math.pi / 2, Vector.Unit_Z)
c = Quaternion(0.0, 0.0, 0.0, 1.0)
self.assertEqual(c, Quaternion.slerp(q1, q2, 0.0))
c = Quaternion(0.0, 0.0, 0.19509033858776093, 0.9807853102684021)
self.assertEqual(c, Quaternion.slerp(q1, q2, 0.25))
c = Quaternion(0.0, 0.0, 0.38268348574638367, 0.9238795638084412)
self.assertEqual(c, Quaternion.slerp(q1, q2, 0.5))
c = Quaternion(0.0, 0.0, 0.5555703043937683, 0.8314696550369263)
self.assertEqual(c, Quaternion.slerp(q1, q2, 0.75))
c = Quaternion(0.0, 0.0, 0.7071068286895752, 0.7071068286895752)
self.assertEqual(c, Quaternion.slerp(q1, q2, 1.0))
示例7: test_multiply
# 需要导入模块: from UM.Math.Quaternion import Quaternion [as 别名]
# 或者: from UM.Math.Quaternion.Quaternion import setByAngleAxis [as 别名]
def test_multiply(self):
q1 = Quaternion()
q1.setByAngleAxis(math.pi / 2, Vector.Unit_Z)
q2 = Quaternion()
q2.setByAngleAxis(math.pi / 2, Vector.Unit_Z)
q3 = q1 * q2
q4 = Quaternion()
q4.setByAngleAxis(math.pi, Vector.Unit_Z)
self.assertEqual(q3, q4)