JerkKinematics { public static double getTimeToReachDisplacement(double displacement, double initialVelocity, double initialAcceleration, double jerk) { ImmutableList<Complex> roots = CubicRootFinder.find(jerk / 6, initialAcceleration / 2, initialVelocity, -displacement); return PolynomialRootUtils.getMinimumPositiveRealRoot(roots); } private  JerkKinematics(); static double getDisplacement(double initialVelocity, double initialAcceleration, double jerk, double time); static double getTimeToReachDisplacement(double displacement, double initialVelocity, double initialAcceleration, double jerk); static double getFinalVelocity(double initialVelocity, double initialAcceleration, double jerk, double time); static double getTimeToReachVelocity(double initialVelocity, double targetVelocity, double initialAcceleration, double jerk);  }
@Test void getTimeToReachDisplacement_whenSuitableValuesGiven_thenGivesCorrectAnswer() { double time = JerkKinematics.getTimeToReachDisplacement(20, 0, 3, 1); Assertions.assertEquals(3.14353, time, 1e-5); }
@Test void getTimeToReachDisplacement_whenUnsuitableValuesGiven_thenThrowsException() { Assertions.assertThrows(IllegalArgumentException.class, () -> JerkKinematics.getTimeToReachDisplacement(20, 1, 1, -5)); }