@Test public void testLineTrajIntersectionSimple() { IVector2 initialPos1 = Vector2.fromXY(-3, 0); IVector2 finalPos1 = Vector2.fromXY(3, 0); IVector2 initialVel1 = Vector2.fromXY(0, 0); IVector2 initialPos2 = Vector2.fromXY(0, -2000); IVector2 finalPos2 = Vector2.fromXY(0, 2000); ILine line = Line.fromPoints(initialPos2, finalPos2); BangBangTrajectory2D traj1 = new BangBangTrajectory2D(initialPos1, finalPos1, initialVel1, 2, 3); List<IVector2> intersections = traj1.getPlanarCurve().getIntersectionsWithLineSegment(line); assertThat(intersections).containsExactlyInAnyOrder(Vector2f.zero()); }
public List<IVector2> getIntersectionsWithLineSegment(final ILine line) { List<IVector2> intersections = new ArrayList<>(); PlanarCurveSegment lineSegment = PlanarCurveSegment.fromFirstOrder(line.supportVector(), line.directionVector(), 0, 1.0); for (PlanarCurveSegment seg : segments) { intersections.addAll(intersections(lineSegment, seg)); } return intersections; }
PlanarCurve { public List<IVector2> getIntersectionsWithLineSegment(final ILine line) { List<IVector2> intersections = new ArrayList<>(); PlanarCurveSegment lineSegment = PlanarCurveSegment.fromFirstOrder(line.supportVector(), line.directionVector(), 0, 1.0); for (PlanarCurveSegment seg : segments) { intersections.addAll(intersections(lineSegment, seg)); } return intersections; } }
PlanarCurve { public List<IVector2> getIntersectionsWithLineSegment(final ILine line) { List<IVector2> intersections = new ArrayList<>(); PlanarCurveSegment lineSegment = PlanarCurveSegment.fromFirstOrder(line.supportVector(), line.directionVector(), 0, 1.0); for (PlanarCurveSegment seg : segments) { intersections.addAll(intersections(lineSegment, seg)); } return intersections; } PlanarCurve(final List<PlanarCurveSegment> segments); }
PlanarCurve { public List<IVector2> getIntersectionsWithLineSegment(final ILine line) { List<IVector2> intersections = new ArrayList<>(); PlanarCurveSegment lineSegment = PlanarCurveSegment.fromFirstOrder(line.supportVector(), line.directionVector(), 0, 1.0); for (PlanarCurveSegment seg : segments) { intersections.addAll(intersections(lineSegment, seg)); } return intersections; } 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); }
PlanarCurve { public List<IVector2> getIntersectionsWithLineSegment(final ILine line) { List<IVector2> intersections = new ArrayList<>(); PlanarCurveSegment lineSegment = PlanarCurveSegment.fromFirstOrder(line.supportVector(), line.directionVector(), 0, 1.0); for (PlanarCurveSegment seg : segments) { intersections.addAll(intersections(lineSegment, seg)); } return intersections; } 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);  }