예제 #1
0
class VecNormTestCase(unittest.TestCase):
	def setUp(self):
		self.v = Vec((5,5))

	def test_norm2(self):
		self.assertEqual(self.v.norm2(), 50)

	def test_norm(self):
		self.assertEqual(round(self.v.norm()), 7)
예제 #2
0
	>>> (v1 * 2) == (2,4,6)
	True
	>>> v1 *= 2
	>>> v1 == (2,4,6)
	True

	>>> (v1 / 2).round() == (1,2,3)
	True
	>>> v1 /= 2
	>>> v1 == (1,2,3)
	True

norm2 & norm
	>>> v = Vec((5,5))
	>>> v.norm2()
	50
	>>> int(v.norm())
	7

normalize
	>>> v = Vec((4,0))
	>>> v.normalize() == (1.0,.0)
	True
	>>> v = Vec((0,4))
	>>> v.normalize() == (.0,1.0)
	True