@Test public void testIntersectLine() { IVector2 directionVector = Vector2f.X_AXIS; ILine line = Line.fromDirection(Vector2f.ZERO_VECTOR, directionVector); for (int degAngle = 0; degAngle <= 180; degAngle++) { double radAngle = Math.toRadians(degAngle); IVector2 curDirectionVector = directionVector.turnNew(radAngle); ILine intersectionLine = Line.fromDirection(Vector2.fromXY(0, 1), curDirectionVector); Optional<IVector2> intersection = line.intersectLine(intersectionLine); Optional<IVector2> inverseIntersection = intersectionLine.intersectLine(line); assertThat(intersection, is(inverseIntersection)); if (degAngle % 180 == 0) { assertThat(intersection, isNotPresent()); } else { double xVal = 1 / SumatraMath.tan(-radAngle); assertThat(intersection, isPresentAnd(is(Vector2.fromXY(xVal, 0)))); } } }
@Override public Optional<IVector2> intersectLine(final ILine other) { if (this.isValid() && other.isValid()) { return LineMath.intersectionPointOfLines(this, other); } return Optional.empty(); }
Line extends AUnboundedLine implements ILine { @Override public Optional<IVector2> intersectLine(final ILine other) { if (this.isValid() && other.isValid()) { return LineMath.intersectionPointOfLines(this, other); } return Optional.empty(); } }
Line extends AUnboundedLine implements ILine { @Override public Optional<IVector2> intersectLine(final ILine other) { if (this.isValid() && other.isValid()) { return LineMath.intersectionPointOfLines(this, other); } return Optional.empty(); } private  Line(final IVector2 supportVector, final IVector2 directionVector); }
Line extends AUnboundedLine implements ILine { @Override public Optional<IVector2> intersectLine(final ILine other) { if (this.isValid() && other.isValid()) { return LineMath.intersectionPointOfLines(this, other); } return Optional.empty(); } private  Line(final IVector2 supportVector, final IVector2 directionVector); static ILine fromPoints(final IVector2 supportPointA, final IVector2 supportPointB); static ILine fromDirection(final IVector2 supportVector, final IVector2 directionVector); @Override ILine copy(); @Override final boolean equals(final Object other); @Override final int hashCode(); @Override Optional<Double> getYIntercept(); @Override Optional<Double> getXValue(final double y); @Override Optional<Double> getYValue(final double x); @Override ILine getOrthogonalLine(); @Override IVector2 closestPointOnLine(final IVector2 point); @Override ILine toLine(); @Override Optional<IVector2> intersectLine(final ILine other); @Override Optional<IVector2> intersectHalfLine(final IHalfLine halfLine); @Override Optional<IVector2> intersectSegment(final ILineSegment segment); @Override String toString(); }
Line extends AUnboundedLine implements ILine { @Override public Optional<IVector2> intersectLine(final ILine other) { if (this.isValid() && other.isValid()) { return LineMath.intersectionPointOfLines(this, other); } return Optional.empty(); } private  Line(final IVector2 supportVector, final IVector2 directionVector); static ILine fromPoints(final IVector2 supportPointA, final IVector2 supportPointB); static ILine fromDirection(final IVector2 supportVector, final IVector2 directionVector); @Override ILine copy(); @Override final boolean equals(final Object other); @Override final int hashCode(); @Override Optional<Double> getYIntercept(); @Override Optional<Double> getXValue(final double y); @Override Optional<Double> getYValue(final double x); @Override ILine getOrthogonalLine(); @Override IVector2 closestPointOnLine(final IVector2 point); @Override ILine toLine(); @Override Optional<IVector2> intersectLine(final ILine other); @Override Optional<IVector2> intersectHalfLine(final IHalfLine halfLine); @Override Optional<IVector2> intersectSegment(final ILineSegment segment); @Override String toString();  }