Exemplo n.º 1
0
    def test_update_motion_returns_same_position_for_no_velocity_or_accel(
            self):
        testObj = Particle(self.positionList)

        dtime = 10

        testObj.update_motion(dtime)

        expected_position = self.positionList

        actual_position = testObj.position

        np.testing.assert_equal(expected_position, actual_position)
Exemplo n.º 2
0
    def test_update_motion_returns_expected_position_for_given_velocity(self):
        testObj = Particle(self.positionList, self.velocity)

        expected_position = np.array(self.positionList)
        constant_velocity = np.array(self.velocity)

        dtime = 10

        testObj.update_motion(10)

        expected_position = expected_position + (constant_velocity * dtime)

        actual_position = testObj.position

        np.testing.assert_equal(expected_position, actual_position)
Exemplo n.º 3
0
    def test_update_motion_returns_expected_position_and_velocity_for_given_accel(
            self):
        testObj = Particle(self.positionList, self.velocity, self.acceleration)

        expected_position = np.array(self.positionList)
        initial_velocity = np.array(self.velocity)
        acceleration = np.array(self.acceleration)

        dtime = 10

        testObj.update_motion(10)

        expected_position = (expected_position + (initial_velocity * dtime) +
                             (acceleration * (dtime**2)) / 2)

        expected_velocity = initial_velocity + (acceleration * dtime)

        actual_position = testObj.position
        actual_velocity = testObj.velocity

        np.testing.assert_equal(expected_position, actual_position)
        np.testing.assert_equal(expected_velocity, actual_velocity)