def setUp(self): self.camera = Camera() self.e1 = numpy.array([1, 0, 0]) self.e2 = numpy.array([0, 1, 0]) self.e3 = numpy.array([0, 0, 1])
def setUp(self): self.camera = Camera() self.e1 = numpy.array([1,0,0]) self.e2 = numpy.array([0,1,0]) self.e3 = numpy.array([0,0,1])
class TestCamera(unittest.TestCase): def setUp(self): self.camera = Camera() self.e1 = numpy.array([1, 0, 0]) self.e2 = numpy.array([0, 1, 0]) self.e3 = numpy.array([0, 0, 1]) def test_initialization(self): self.assertTrue(numpy.allclose(self.e1, self.camera.right)) self.assertTrue(numpy.allclose(self.e2, self.camera.up)) self.assertTrue(numpy.allclose(self.e3, self.camera.backward)) def test_rotation(self): self.camera.yaw(math.pi / 120.0) angle = self.camera.orientation.angle() axis = self.camera.orientation.axis() self.assertAlmostEqual(math.pi / 120.0, angle, places=3) self.assertTrue(numpy.allclose(self.e2, axis)) def test_move_forward(self): self.camera.position = self.e3 self.camera.yaw(-math.pi / 4.0) self.camera.move_forward(math.sqrt(2.0)) self.assertTrue( numpy.allclose(self.e1, self.camera.position, atol=1e-6)) def test_rotation_accumulation(self): self.camera.move_backward(1.0) self.camera.move_right(1.0) self.camera.move_up(1.0) for _ in range(27): self.camera.yaw(math.pi / 12.0) self.camera.move_right(math.sqrt(2.0))
class TestCamera(unittest.TestCase): def setUp(self): self.camera = Camera() self.e1 = numpy.array([1,0,0]) self.e2 = numpy.array([0,1,0]) self.e3 = numpy.array([0,0,1]) def test_initialization(self): self.assertTrue(numpy.allclose(self.e1, self.camera.right)) self.assertTrue(numpy.allclose(self.e2, self.camera.up)) self.assertTrue(numpy.allclose(self.e3, self.camera.backward)) def test_rotation(self): self.camera.yaw(math.pi / 120.0) angle = self.camera.orientation.angle() axis = self.camera.orientation.axis() self.assertAlmostEqual(math.pi / 120.0, angle, places = 3) self.assertTrue(numpy.allclose(self.e2, axis)) def test_move_forward(self): self.camera.position = self.e3 self.camera.yaw(-math.pi / 4.0) self.camera.move_forward(math.sqrt(2.0)) self.assertTrue(numpy.allclose(self.e1, self.camera.position, atol=1e-6)) def test_rotation_accumulation(self): self.camera.move_backward(1.0) self.camera.move_right(1.0) self.camera.move_up(1.0) for _ in xrange(27): self.camera.yaw(math.pi / 12.0) self.camera.move_right(math.sqrt(2.0))