本文整理汇总了Python中UM.Math.Vector.Vector.angleToVector方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.angleToVector方法的具体用法?Python Vector.angleToVector怎么用?Python Vector.angleToVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UM.Math.Vector.Vector
的用法示例。
在下文中一共展示了Vector.angleToVector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestVector
# 需要导入模块: from UM.Math.Vector import Vector [as 别名]
# 或者: from UM.Math.Vector.Vector import angleToVector [as 别名]
class TestVector(unittest.TestCase):
def setUp(self):
# Called before the first testfunction is executed
self._vector = Vector(1, 0, 0)
pass
def tearDown(self):
# Called after the last testfunction was executed
pass
def test_getData(self):
numpy.testing.assert_array_almost_equal(self._vector.getData(), numpy.array([1, 0, 0]))
pass
def test_angleBetweenVectors(self):
second_vector = Vector(1, 0, 0)
third_vector = Vector(0, 1, 0)
fourth_vector = Vector(0, 0, 1)
# Check if angle with itself is 0
self.assertEqual(self._vector.angleToVector(second_vector), 0)
# Check if angle between the two vectors that are rotated in equal angle but different direction are the same
self.assertEqual(self._vector.angleToVector(third_vector), self._vector.angleToVector(fourth_vector))
def test_normalize(self):
pass
def test_setValues(self):
x = 10
y = 10
z = 10
temp_vector = Vector(x, y, z)
numpy.testing.assert_array_almost_equal(temp_vector.getData(), numpy.array([x, y, z]))
def test_negPos(self):
v = Vector(0, 1, 0)
self.assertEqual(Vector(0, -1, 0), -v)
self.assertEqual(Vector(0, 1, 0), v) # - should have no side effects
示例2: TestVector
# 需要导入模块: from UM.Math.Vector import Vector [as 别名]
# 或者: from UM.Math.Vector.Vector import angleToVector [as 别名]
class TestVector(unittest.TestCase):
def setUp(self):
# Called before the first testfunction is executed
self._vector = Vector(1,0,0)
pass
def tearDown(self):
# Called after the last testfunction was executed
pass
def test_getData(self):
numpy.testing.assert_array_almost_equal(self._vector.getData(), numpy.array([1,0,0]))
def test_angleBetweenVectors(self):
second_vector = Vector(1,0,0)
third_vector = Vector(0,1,0)
fourth_vector = Vector(0,0,1)
# Check if angle with itself is 0
self.assertEqual(self._vector.angleToVector(second_vector), 0)
# Check if angle between the two vectors that are rotated in equal angle but different direction are the same
self.assertEqual(self._vector.angleToVector(third_vector), self._vector.angleToVector(fourth_vector))
def test_normalize(self):
vector = Vector(10, 10, 10)
assert vector.normalized().length() == 1
def test_setValues(self):
x = 10
y = 10
z = 10
temp_vector = Vector(x,y,z)
numpy.testing.assert_array_almost_equal(temp_vector.getData(), numpy.array([x,y,z]))
temp_vector2 = temp_vector.set(1, 2, 3)
numpy.testing.assert_array_almost_equal(temp_vector2.getData(), numpy.array([1, 2, 3]))
def test_negPos(self):
v = Vector(0, 1, 0)
self.assertEqual(Vector(0, -1, 0), -v)
self.assertEqual(Vector(0, 1, 0), v) # - should have no side effects
def test_compare(self):
short_vector = Vector(0, 1, 0)
long_vector = Vector(200, 300, 500)
assert short_vector < long_vector
assert long_vector > short_vector
assert not long_vector == None
def test_add(self):
vector = Vector(0, 1, 0)
vector2 = Vector(1, 0, 1)
assert vector + vector2 == Vector(1, 1, 1)
assert vector + vector2.getData() == Vector(1, 1, 1)
vector += vector2
assert vector == Vector(1, 1, 1)
def test_subtract(self):
vector = Vector(2, 2, 2)
vector2 = Vector(1, 1, 1)
assert vector - vector2 == Vector(1, 1, 1)
assert vector - vector2.getData() == Vector(1, 1, 1)
assert vector2 - vector == Vector(-1, -1, -1)
assert vector2 - vector.getData() == Vector(-1, -1, -1)
vector -= vector2
assert vector == Vector(1, 1, 1)
def test_multiply(self):
vector = Vector(2, 2, 2)
vector2 = Vector(2, 2, 2)
assert vector * vector2 == Vector(4, 4, 4)
assert vector * 2 == Vector(4, 4, 4)
assert vector.scale(vector2) == Vector(4, 4, 4)
vector *= vector2
assert vector == Vector(4, 4, 4)