JerkKinematics { public static double getTimeToReachVelocity(double initialVelocity, double targetVelocity, double initialAcceleration, double jerk) { ImmutableList<Complex> roots = QuadraticRootFinder.find(jerk / 2d, initialAcceleration, initialVelocity - targetVelocity); 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 getTimeToReachVelocity_whenSuitableValuesGiven_thenGivesCorrectAnswer() { double time = JerkKinematics.getTimeToReachVelocity(0, 20, 3, 1); Assertions.assertEquals(4, time, 1e-5); }
@Test void getTimeToReachVelocity_whenUnsuitableValuesGiven_thenThrowsException() { Assertions.assertThrows(IllegalArgumentException.class, () -> JerkKinematics.getTimeToReachVelocity(0, 20, 1, -5)); }