def test_magnitude_of_velocity_is_given_by_pythagoras_theorem(self): start_position = Position() end_position = Position(4, 3) velocity = Velocity(start_position, end_position) self.assertEquals(5, velocity.magnitude())
def test_angle_of_velocity_is_determined_by_the_arctangent(self): start_position = Position() end_posotion = Position(3, 4) velocity = Velocity(start_position, end_posotion) self.assertTrue(velocity.angle() > 45) self.assertTrue(velocity.angle() < 90)
def test_angle_of_velocity_is_45_if_x_and_y_of_end_position_are_the_same( self): start_position = Position() end_position = Position(2, 2) velocity = Velocity(start_position, end_position) self.assertEquals(45, velocity.angle())
def test_create_velocity_with_two_positions(self): start_position = Position() end_position = Position(4, 3) velocity = Velocity(start_position, end_position) self.assertIsNotNone(velocity)
def test_position_changes_when_projectile_is_shoot(self): initial_position = Position() projectile = Projectile(Position()) velocity = Velocity(Position(), Position(3, 5)) projectile.shoot(velocity) self.assertTrue(isinstance(projectile.position())) self.assertNotEquals(initial_position(), projectile.position())
def test_magnitude_is_zero_if_start_and_end_positions_are_the_same(self): position = Position(1, 1) velocity = Velocity(position, position) self.assertEquals(0, velocity.magnitude())
def test_projectile_shot_with_a_given_angle_follows_a_parabolic_path(self): projectile = Projectile(Position(0, 3)) velocity = Velocity(Position(0, 3), Position(4, 6)) projectile.shoot(velocity) self.assertEquals(Position(3, 0), projectile.position())