def test_3axis_movement(self): my_obj = cg.WorldObject() # We should be able to move the object multiple times and the position will move but not direction move_vector = np.array((1, 2, -5)) my_obj.move(*move_vector) # move the object in space self.assertTrue( np.array_equal(my_obj.get_position(), cg.Point(*move_vector))) # reversing the move gets you back to the origin my_obj.move(*(-move_vector)) # move the object in space self.assertTrue(np.array_equal(my_obj.get_position(), cg.Point()))
def test_scale_all(self): scale_factor = 1000 expected_pos = scale_factor * np.ones(3) self._obj.scale_all(scale_factor) self.assertTrue( np.allclose(self._obj.get_position(), cg.Point(*expected_pos)), f"{self._obj.get_position()}")
def test_chained_scale(self): scale_values = (3, 4, 5) self._obj.scale_x(scale_values[0]).scale_y(scale_values[1]).scale_z( scale_values[2]) self.assertTrue( np.allclose(self._obj.get_position(), cg.Point(*scale_values)), f"{self._obj.get_position()}")
def test_single_axis_scale(self): # move the object to 1,1,1 so that the scale effects it scale_axes = "xyz" scale_fns = [ getattr(self._obj, "scale_" + axis) for axis in scale_axes ] scale_values = [3, 4, 5] for fn, scale in zip(scale_fns, scale_values): fn(scale) self.assertTrue( np.allclose(self._obj.get_position(), cg.Point(*scale_values)), f"{self._obj.get_position()}")
def test_3axis_scale(self): scale_values = (3, 4, 5) self._obj.scale(*scale_values) self.assertTrue( np.allclose(self._obj.get_position(), cg.Point(*scale_values)), f"{self._obj.get_position()}")
def test_object_creation(self): # the object should be centered at the origin facing the positive z-axis self.assertTrue( np.array_equal(self._obj.get_position(), cg.Point(0, 0, 0))) self.assertTrue( np.array_equal(self._obj.get_orientation(), cg.Vector(0, 0, 1)))
def setUp(self): self.coord = cg.Point(3, 4, 5)
def test_chained_movement(self): movement = 3 self._obj.move_x(movement).move_y(movement).move_z(movement) self.assertTrue( np.array_equal(self._obj.get_position(), cg.Point(movement, movement, movement)))