def test_centripetal_acceleration_straight_line(self): trajectory = spline.SplineTrajectorySegment([0, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0]) point = spline.SplineTrajectoryPoint(trajectory, 0) npt.assert_almost_equal([0, 0, 0], point.centripetal_acceleration)
def test_centripetal_acceleration_curve(self): trajectory = spline.SplineTrajectorySegment([0, 0, 0], [1, 1, 0], [1, 0, 0], [0, 1, 0]) point = spline.SplineTrajectoryPoint(trajectory, 0) self.assertAlmostEqual(0, point.centripetal_acceleration[0]) self.assertLess(0, point.centripetal_acceleration[1]) self.assertAlmostEqual(0, point.centripetal_acceleration[2])
def test_parametrization_at_distance(self): trajectory = spline.SplineTrajectorySegment([0, 1, 2], [-1, -2, -3], [1, 1, 1], [1, 1, 1]) r = trajectory.parametrization_at_distance(trajectory.spline_length / 3) length = trajectory.section_length(0, r) self.assertAlmostEqual(trajectory.spline_length / 3, length)
def test_section_length(self): trajectory = spline.SplineTrajectorySegment([0, 1, 2], [-1, -2, -3], [1, 1, 1], [1, 1, 1]) sa = trajectory.section_length(0, 0.5) sb = trajectory.section_length(0.5, 1) sab = trajectory.section_length(0, 1) self.assertAlmostEqual(sa + sb, sab)
def test_start_and_end_derivatives_3D(self): d1 = [1, 1, 1] d2 = [1, 2, 3] trajectory = spline.SplineTrajectorySegment([0, 1, 2], [-1, -2, -3], d1, d2) npt.assert_almost_equal(normalize(d1), normalize(trajectory.spline_dot(0))) npt.assert_almost_equal(normalize(d2), normalize(trajectory.spline_dot(1)))
def test_start_and_end_postions_3D(self): trajectory = spline.SplineTrajectorySegment([0, 1, 2], [-1, -2, -3], [1, 1, 1], [1, 1, 1]) npt.assert_almost_equal([0, 1, 2], trajectory.spline(0)) npt.assert_almost_equal([-1, -2, -3], trajectory.spline(1))
def test_start_and_end_postions_1D(self): trajectory = spline.SplineTrajectorySegment([0], [1], [1], [1]) npt.assert_almost_equal([0], trajectory.spline(0)) npt.assert_almost_equal([1], trajectory.spline(1))