@Test public void isBehindPenaltyArea() { assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(0, 0))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(borderX, 0))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(borderX + 1, 0))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX + 1, 0))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX, 0))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX, length))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX, length / 2))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX, length / 4))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX, -length))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX, -length / 2))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX, -length / 4))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX - 1, 0))).isTrue(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX - 1, length / 2 - 1))).isTrue(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX - 1, -length / 2 + 1))).isTrue(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX - 1, length / 4))).isTrue(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX - 1, -length / 4))).isTrue(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX - 1, length / 2))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX - 1, -length / 2))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX - 1, -length))).isFalse(); assertThat(penaltyArea.isBehindPenaltyArea(Vector2.fromXY(goalX - 1, length))).isFalse(); }
@Override public boolean isBehindPenaltyArea(final IVector2 point) { return (Math.abs(point.x()) > Math.abs(getGoalCenter().x())) && ((int) Math.signum(point.x()) == (int) Math.signum(getGoalCenter().x())) && Math.abs(point.y()) < getLength() / 2; }
PenaltyArea implements IPenaltyArea { @Override public boolean isBehindPenaltyArea(final IVector2 point) { return (Math.abs(point.x()) > Math.abs(getGoalCenter().x())) && ((int) Math.signum(point.x()) == (int) Math.signum(getGoalCenter().x())) && Math.abs(point.y()) < getLength() / 2; } }
PenaltyArea implements IPenaltyArea { @Override public boolean isBehindPenaltyArea(final IVector2 point) { return (Math.abs(point.x()) > Math.abs(getGoalCenter().x())) && ((int) Math.signum(point.x()) == (int) Math.signum(getGoalCenter().x())) && Math.abs(point.y()) < getLength() / 2; } PenaltyArea(final IVector2 goalCenter, final double depth, final double length); }
PenaltyArea implements IPenaltyArea { @Override public boolean isBehindPenaltyArea(final IVector2 point) { return (Math.abs(point.x()) > Math.abs(getGoalCenter().x())) && ((int) Math.signum(point.x()) == (int) Math.signum(getGoalCenter().x())) && Math.abs(point.y()) < getLength() / 2; } PenaltyArea(final IVector2 goalCenter, final double depth, final double length); @Override IPenaltyArea withMargin(final double margin); @Override List<IVector2> lineIntersections(final edu.tigers.sumatra.math.line.v2.ILine line); @Override List<IVector2> lineIntersections(final ILineSegment line); @Override List<IVector2> lineIntersections(final IHalfLine line); @Override List<IVector2> lineIntersections(final ILine line); @Override @SuppressWarnings("squid:S1244") // equality check intended IVector2 projectPointOnToPenaltyAreaBorder(final IVector2 point); @Override boolean isPointInShape(final IVector2 point); @Override boolean isPointInShape(final IVector2 point, final double margin); @Override boolean isPointInShapeOrBehind(final IVector2 point); @Override IVector2 nearestPointInside(final IVector2 point); @Override IVector2 nearestPointOutside(final IVector2 point); @Override boolean isIntersectingWithLine(final ILine line); @Override boolean isBehindPenaltyArea(final IVector2 point); @Override IVector2 getGoalCenter(); @Override Rectangle getRectangle(); @Override IVector2 getNegCorner(); @Override IVector2 getPosCorner(); @Override List<IDrawableShape> getDrawableShapes(); @Override double distanceTo(final IVector2 point); @Override double distanceToNearestPointOutside(final IVector2 pos); @Override double intersectionArea(final IVector2 from, final IVector2 to); }
PenaltyArea implements IPenaltyArea { @Override public boolean isBehindPenaltyArea(final IVector2 point) { return (Math.abs(point.x()) > Math.abs(getGoalCenter().x())) && ((int) Math.signum(point.x()) == (int) Math.signum(getGoalCenter().x())) && Math.abs(point.y()) < getLength() / 2; } PenaltyArea(final IVector2 goalCenter, final double depth, final double length); @Override IPenaltyArea withMargin(final double margin); @Override List<IVector2> lineIntersections(final edu.tigers.sumatra.math.line.v2.ILine line); @Override List<IVector2> lineIntersections(final ILineSegment line); @Override List<IVector2> lineIntersections(final IHalfLine line); @Override List<IVector2> lineIntersections(final ILine line); @Override @SuppressWarnings("squid:S1244") // equality check intended IVector2 projectPointOnToPenaltyAreaBorder(final IVector2 point); @Override boolean isPointInShape(final IVector2 point); @Override boolean isPointInShape(final IVector2 point, final double margin); @Override boolean isPointInShapeOrBehind(final IVector2 point); @Override IVector2 nearestPointInside(final IVector2 point); @Override IVector2 nearestPointOutside(final IVector2 point); @Override boolean isIntersectingWithLine(final ILine line); @Override boolean isBehindPenaltyArea(final IVector2 point); @Override IVector2 getGoalCenter(); @Override Rectangle getRectangle(); @Override IVector2 getNegCorner(); @Override IVector2 getPosCorner(); @Override List<IDrawableShape> getDrawableShapes(); @Override double distanceTo(final IVector2 point); @Override double distanceToNearestPointOutside(final IVector2 pos); @Override double intersectionArea(final IVector2 from, final IVector2 to);  }