### Question:
PlanarCurve { public double getMinimumDistanceToPoint(final IVector2 point) { return getMinimumDistanceToCurve(PlanarCurve.fromPoint(point)); } PlanarCurve(final List<PlanarCurveSegment> segments); List<PlanarCurveSegment> getSegments(); double getTEnd(); static PlanarCurve fromPoint(final IVector2 point); static PlanarCurve fromPositionAndVelocity(final IVector2 pos, final IVector2 vel, final double tEnd); static PlanarCurve fromPositionVelocityAndAcceleration(final IVector2 pos, final IVector2 vel,
			final IVector2 acc, final double tEnd); PlanarCurve restrictToEnd(final double tEnd); PlanarCurve restrictToStart(final double tStart); double getMinimumDistanceToPoint(final IVector2 point); double getMinimumDistanceToCurve(final PlanarCurve curve); List<IVector2> getIntersectionsWithLineSegment(final ILine line); List<IVector2> getIntersectionsWithRectangle(final IRectangle rect);  }### Answer:
@Test public void testGetMinimumDistanceSimple() { IVector2 initialPos = Vector2.fromXY(0, 0); IVector2 finalPos = Vector2.fromXY(3, 0); IVector2 initialVel = Vector2f.ZERO_VECTOR; IVector2 testPoint = Vector2.fromXY(1.5, 1); BangBangTrajectory2D traj = new BangBangTrajectory2D(initialPos, finalPos, initialVel, 2, 3); double dist = traj.getPlanarCurve().getMinimumDistanceToPoint(testPoint); assertThat(dist).isCloseTo(1.0, within(1e-6)); }
@Test public void testGetMinimumDistanceRandom() { for (int i = 0; i < NUMBER_OF_TESTS; i++) { IVector2 initPos = getRandomVector(POS_LIMIT); IVector2 finalPos = getRandomVector(POS_LIMIT); IVector2 initVel = getRandomVector(2.0); IVector2 testPoint = getRandomVector(5.0 * 1e3); BangBangTrajectory2D traj = new BangBangTrajectory2D(initPos, finalPos, initVel, 2.0, 3.0); double dist = traj.getPlanarCurve().getMinimumDistanceToPoint(testPoint); double sampleDist = sampleDistMin(traj, testPoint, 1e-3); assertThat(dist).isCloseTo(sampleDist, within(2.0)); } }