@Test public void testGetMinimumDistanceTrajBall() { IVector2 initialPos1 = Vector2.fromXY(2, -2); IVector2 finalPos1 = Vector2.fromXY(2, 4); IVector2 initialVel1 = Vector2f.ZERO_VECTOR; BangBangTrajectory2D traj1 = new BangBangTrajectory2D(initialPos1, finalPos1, initialVel1, 2, 3); double dist = traj1.getPlanarCurve().getMinimumDistanceToCurve(trajectory.getPlanarCurve()); double sampleDist = sampleDistMin(traj1, trajectory, 1e-3); assertEquals(sampleDist, dist, 1); }
@Override public PlanarCurve getPlanarCurve() { List<PlanarCurveSegment> segments = new ArrayList<>(); BallTrajectoryState state = getMilliStateAtTime(tKickToNow); double tRest = getTimeAtRest(); if (tKickToNow > tRest) { segments.add(PlanarCurveSegment.fromPoint(state.getPos().getXYVector(), 0, 1.0)); return new PlanarCurve(segments); } Vector3 posNow = Vector3.copy(state.getPos().getXYZVector()); Vector3 velNow = Vector3.copy(state.getVel().getXYZVector()); double tNow = 0; double spin = initialSpin; while (((velNow.z() * velNow.z()) / (2.0 * G)) > params.getMinHopHeight()) { double tFly = (2 * velNow.z()) / G; PlanarCurveSegment fly = PlanarCurveSegment.fromFirstOrder(posNow.getXYVector(), velNow.getXYVector(), tNow, tNow + tFly); segments.add(fly); posNow.add(velNow.multiplyNew(tFly)); posNow.set(2, 0); velNow = velNow.multiplyNew(getDamping(spin)); tNow += tFly; spin = 1.0; } velNow.set(2, 0); Vector3 accNow = velNow.normalizeNew().multiply(params.getAccRoll()); double tStop = -velNow.getLength2() / params.getAccRoll(); PlanarCurveSegment roll = PlanarCurveSegment.fromSecondOrder(posNow.getXYVector(), velNow.getXYVector(), accNow.getXYVector(), tNow, tNow + tStop); segments.add(roll); return new PlanarCurve(segments); }
FixedLossPlusRollingBallTrajectory extends ABallTrajectory { @Override public PlanarCurve getPlanarCurve() { List<PlanarCurveSegment> segments = new ArrayList<>(); BallTrajectoryState state = getMilliStateAtTime(tKickToNow); double tRest = getTimeAtRest(); if (tKickToNow > tRest) { segments.add(PlanarCurveSegment.fromPoint(state.getPos().getXYVector(), 0, 1.0)); return new PlanarCurve(segments); } Vector3 posNow = Vector3.copy(state.getPos().getXYZVector()); Vector3 velNow = Vector3.copy(state.getVel().getXYZVector()); double tNow = 0; double spin = initialSpin; while (((velNow.z() * velNow.z()) / (2.0 * G)) > params.getMinHopHeight()) { double tFly = (2 * velNow.z()) / G; PlanarCurveSegment fly = PlanarCurveSegment.fromFirstOrder(posNow.getXYVector(), velNow.getXYVector(), tNow, tNow + tFly); segments.add(fly); posNow.add(velNow.multiplyNew(tFly)); posNow.set(2, 0); velNow = velNow.multiplyNew(getDamping(spin)); tNow += tFly; spin = 1.0; } velNow.set(2, 0); Vector3 accNow = velNow.normalizeNew().multiply(params.getAccRoll()); double tStop = -velNow.getLength2() / params.getAccRoll(); PlanarCurveSegment roll = PlanarCurveSegment.fromSecondOrder(posNow.getXYVector(), velNow.getXYVector(), accNow.getXYVector(), tNow, tNow + tStop); segments.add(roll); return new PlanarCurve(segments); } }
FixedLossPlusRollingBallTrajectory extends ABallTrajectory { @Override public PlanarCurve getPlanarCurve() { List<PlanarCurveSegment> segments = new ArrayList<>(); BallTrajectoryState state = getMilliStateAtTime(tKickToNow); double tRest = getTimeAtRest(); if (tKickToNow > tRest) { segments.add(PlanarCurveSegment.fromPoint(state.getPos().getXYVector(), 0, 1.0)); return new PlanarCurve(segments); } Vector3 posNow = Vector3.copy(state.getPos().getXYZVector()); Vector3 velNow = Vector3.copy(state.getVel().getXYZVector()); double tNow = 0; double spin = initialSpin; while (((velNow.z() * velNow.z()) / (2.0 * G)) > params.getMinHopHeight()) { double tFly = (2 * velNow.z()) / G; PlanarCurveSegment fly = PlanarCurveSegment.fromFirstOrder(posNow.getXYVector(), velNow.getXYVector(), tNow, tNow + tFly); segments.add(fly); posNow.add(velNow.multiplyNew(tFly)); posNow.set(2, 0); velNow = velNow.multiplyNew(getDamping(spin)); tNow += tFly; spin = 1.0; } velNow.set(2, 0); Vector3 accNow = velNow.normalizeNew().multiply(params.getAccRoll()); double tStop = -velNow.getLength2() / params.getAccRoll(); PlanarCurveSegment roll = PlanarCurveSegment.fromSecondOrder(posNow.getXYVector(), velNow.getXYVector(), accNow.getXYVector(), tNow, tNow + tStop); segments.add(roll); return new PlanarCurve(segments); } protected  FixedLossPlusRollingBallTrajectory(final IVector3 kickPos, final IVector3 kickVel, final double tKickToNow,
			final double initialSpin, final FixedLossPlusRollingParameters params); }
FixedLossPlusRollingBallTrajectory extends ABallTrajectory { @Override public PlanarCurve getPlanarCurve() { List<PlanarCurveSegment> segments = new ArrayList<>(); BallTrajectoryState state = getMilliStateAtTime(tKickToNow); double tRest = getTimeAtRest(); if (tKickToNow > tRest) { segments.add(PlanarCurveSegment.fromPoint(state.getPos().getXYVector(), 0, 1.0)); return new PlanarCurve(segments); } Vector3 posNow = Vector3.copy(state.getPos().getXYZVector()); Vector3 velNow = Vector3.copy(state.getVel().getXYZVector()); double tNow = 0; double spin = initialSpin; while (((velNow.z() * velNow.z()) / (2.0 * G)) > params.getMinHopHeight()) { double tFly = (2 * velNow.z()) / G; PlanarCurveSegment fly = PlanarCurveSegment.fromFirstOrder(posNow.getXYVector(), velNow.getXYVector(), tNow, tNow + tFly); segments.add(fly); posNow.add(velNow.multiplyNew(tFly)); posNow.set(2, 0); velNow = velNow.multiplyNew(getDamping(spin)); tNow += tFly; spin = 1.0; } velNow.set(2, 0); Vector3 accNow = velNow.normalizeNew().multiply(params.getAccRoll()); double tStop = -velNow.getLength2() / params.getAccRoll(); PlanarCurveSegment roll = PlanarCurveSegment.fromSecondOrder(posNow.getXYVector(), velNow.getXYVector(), accNow.getXYVector(), tNow, tNow + tStop); segments.add(roll); return new PlanarCurve(segments); } protected  FixedLossPlusRollingBallTrajectory(final IVector3 kickPos, final IVector3 kickVel, final double tKickToNow,
			final double initialSpin, final FixedLossPlusRollingParameters params); static FixedLossPlusRollingBallTrajectory fromKick(final IVector2 kickPos, final IVector3 kickVel,
			final double spin, final FixedLossPlusRollingParameters params); static FixedLossPlusRollingBallTrajectory fromState(final IVector3 posNow, final IVector3 velNow,
			final double spin, final FixedLossPlusRollingParameters params); @Override BallTrajectoryState getMilliStateAtTime(final double time); @Override PlanarCurve getPlanarCurve(); @Override double getTimeAtRest(); @Override ABallTrajectory mirrored(); @Override List<IVector2> getTouchdownLocations(); @Override ILineSegment getTravelLineRolling(); @Override List<ILineSegment> getTravelLinesInterceptable(); }
FixedLossPlusRollingBallTrajectory extends ABallTrajectory { @Override public PlanarCurve getPlanarCurve() { List<PlanarCurveSegment> segments = new ArrayList<>(); BallTrajectoryState state = getMilliStateAtTime(tKickToNow); double tRest = getTimeAtRest(); if (tKickToNow > tRest) { segments.add(PlanarCurveSegment.fromPoint(state.getPos().getXYVector(), 0, 1.0)); return new PlanarCurve(segments); } Vector3 posNow = Vector3.copy(state.getPos().getXYZVector()); Vector3 velNow = Vector3.copy(state.getVel().getXYZVector()); double tNow = 0; double spin = initialSpin; while (((velNow.z() * velNow.z()) / (2.0 * G)) > params.getMinHopHeight()) { double tFly = (2 * velNow.z()) / G; PlanarCurveSegment fly = PlanarCurveSegment.fromFirstOrder(posNow.getXYVector(), velNow.getXYVector(), tNow, tNow + tFly); segments.add(fly); posNow.add(velNow.multiplyNew(tFly)); posNow.set(2, 0); velNow = velNow.multiplyNew(getDamping(spin)); tNow += tFly; spin = 1.0; } velNow.set(2, 0); Vector3 accNow = velNow.normalizeNew().multiply(params.getAccRoll()); double tStop = -velNow.getLength2() / params.getAccRoll(); PlanarCurveSegment roll = PlanarCurveSegment.fromSecondOrder(posNow.getXYVector(), velNow.getXYVector(), accNow.getXYVector(), tNow, tNow + tStop); segments.add(roll); return new PlanarCurve(segments); } protected  FixedLossPlusRollingBallTrajectory(final IVector3 kickPos, final IVector3 kickVel, final double tKickToNow,
			final double initialSpin, final FixedLossPlusRollingParameters params); static FixedLossPlusRollingBallTrajectory fromKick(final IVector2 kickPos, final IVector3 kickVel,
			final double spin, final FixedLossPlusRollingParameters params); static FixedLossPlusRollingBallTrajectory fromState(final IVector3 posNow, final IVector3 velNow,
			final double spin, final FixedLossPlusRollingParameters params); @Override BallTrajectoryState getMilliStateAtTime(final double time); @Override PlanarCurve getPlanarCurve(); @Override double getTimeAtRest(); @Override ABallTrajectory mirrored(); @Override List<IVector2> getTouchdownLocations(); @Override ILineSegment getTravelLineRolling(); @Override List<ILineSegment> getTravelLinesInterceptable();  }