@Test public void testGetTriangle() { IVector2 origin = Geometry.getCenter(); IVector2 leftPost = Geometry.getGoalTheir().getLeftPost(); IVector2 rightPost = Geometry.getGoalTheir().getRightPost(); IVector2 pointInGoal = Geometry.getGoalTheir().getCenter() .addNew(Vector2.fromX(Geometry.getGoalTheir().getDepth() / 2)); ITriangle triangle = AngleRaterMath.getTriangle(leftPost, rightPost, false, origin); assertThat(triangle.getCorners()).as("Check corners equal to arguments").contains(origin, leftPost, rightPost); assertThat(triangle.isPointInShape(pointInGoal)).as("Check point in goal (normal triangle)").isFalse(); triangle = AngleRaterMath.getTriangle(leftPost, rightPost, true, origin); assertThat(triangle.isPointInShape(pointInGoal)).as("Check point in goal (extended triangle)").isTrue(); assertThat(Lines.segmentFromPoints(triangle.getA(), triangle.getB()).getLength()) .as("Check line length") .isEqualTo(Lines.segmentFromPoints(triangle.getA(), triangle.getC()).getLength(), Offset.offset(1e-4)); origin = leftPost.subtractNew(Vector2.fromX(500)); triangle = AngleRaterMath.getTriangle(leftPost, rightPost, true, origin); assertThat(triangle.isPointInShape(pointInGoal)).as("Check point in goal (straight line)").isTrue(); assertThat(Lines.segmentFromPoints(triangle.getA(), triangle.getB()).getLength()) .as("Check line length (straight line)") .isLessThan(Lines.segmentFromPoints(triangle.getA(), triangle.getC()).getLength()); }
public static ITriangle getTriangle(final IVector2 endLeft, final IVector2 endRight, final boolean extend, final IVector2 start) { IVector2 left = endLeft; IVector2 right = endRight; if (extend) { IVector2 leftLine = endLeft.subtractNew(start); IVector2 rightLine = endRight.subtractNew(start); double goalDepth = Math.max(Geometry.getGoalOur().getDepth(), Geometry.getGoalTheir().getDepth()); double extensionLeft = goalDepth / AngleMath.cos(Vector2.fromX(leftLine.x()).angleToAbs(leftLine).orElse(0.0)); double extensionRight = goalDepth / AngleMath.cos(Vector2.fromX(rightLine.x()).angleToAbs(rightLine).orElse(0.0)); left = endLeft.addNew(leftLine.scaleToNew(extensionLeft)); right = endRight.addNew(rightLine.scaleToNew(extensionRight)); } return Triangle.fromCorners(start, left, right); }
AngleRaterMath { public static ITriangle getTriangle(final IVector2 endLeft, final IVector2 endRight, final boolean extend, final IVector2 start) { IVector2 left = endLeft; IVector2 right = endRight; if (extend) { IVector2 leftLine = endLeft.subtractNew(start); IVector2 rightLine = endRight.subtractNew(start); double goalDepth = Math.max(Geometry.getGoalOur().getDepth(), Geometry.getGoalTheir().getDepth()); double extensionLeft = goalDepth / AngleMath.cos(Vector2.fromX(leftLine.x()).angleToAbs(leftLine).orElse(0.0)); double extensionRight = goalDepth / AngleMath.cos(Vector2.fromX(rightLine.x()).angleToAbs(rightLine).orElse(0.0)); left = endLeft.addNew(leftLine.scaleToNew(extensionLeft)); right = endRight.addNew(rightLine.scaleToNew(extensionRight)); } return Triangle.fromCorners(start, left, right); } }
AngleRaterMath { public static ITriangle getTriangle(final IVector2 endLeft, final IVector2 endRight, final boolean extend, final IVector2 start) { IVector2 left = endLeft; IVector2 right = endRight; if (extend) { IVector2 leftLine = endLeft.subtractNew(start); IVector2 rightLine = endRight.subtractNew(start); double goalDepth = Math.max(Geometry.getGoalOur().getDepth(), Geometry.getGoalTheir().getDepth()); double extensionLeft = goalDepth / AngleMath.cos(Vector2.fromX(leftLine.x()).angleToAbs(leftLine).orElse(0.0)); double extensionRight = goalDepth / AngleMath.cos(Vector2.fromX(rightLine.x()).angleToAbs(rightLine).orElse(0.0)); left = endLeft.addNew(leftLine.scaleToNew(extensionLeft)); right = endRight.addNew(rightLine.scaleToNew(extensionRight)); } return Triangle.fromCorners(start, left, right); } private  AngleRaterMath(); }
AngleRaterMath { public static ITriangle getTriangle(final IVector2 endLeft, final IVector2 endRight, final boolean extend, final IVector2 start) { IVector2 left = endLeft; IVector2 right = endRight; if (extend) { IVector2 leftLine = endLeft.subtractNew(start); IVector2 rightLine = endRight.subtractNew(start); double goalDepth = Math.max(Geometry.getGoalOur().getDepth(), Geometry.getGoalTheir().getDepth()); double extensionLeft = goalDepth / AngleMath.cos(Vector2.fromX(leftLine.x()).angleToAbs(leftLine).orElse(0.0)); double extensionRight = goalDepth / AngleMath.cos(Vector2.fromX(rightLine.x()).angleToAbs(rightLine).orElse(0.0)); left = endLeft.addNew(leftLine.scaleToNew(extensionLeft)); right = endRight.addNew(rightLine.scaleToNew(extensionRight)); } return Triangle.fromCorners(start, left, right); } private  AngleRaterMath(); static ITriangle getTriangle(final IVector2 endLeft, final IVector2 endRight, final boolean extend,
			final IVector2 start); }
AngleRaterMath { public static ITriangle getTriangle(final IVector2 endLeft, final IVector2 endRight, final boolean extend, final IVector2 start) { IVector2 left = endLeft; IVector2 right = endRight; if (extend) { IVector2 leftLine = endLeft.subtractNew(start); IVector2 rightLine = endRight.subtractNew(start); double goalDepth = Math.max(Geometry.getGoalOur().getDepth(), Geometry.getGoalTheir().getDepth()); double extensionLeft = goalDepth / AngleMath.cos(Vector2.fromX(leftLine.x()).angleToAbs(leftLine).orElse(0.0)); double extensionRight = goalDepth / AngleMath.cos(Vector2.fromX(rightLine.x()).angleToAbs(rightLine).orElse(0.0)); left = endLeft.addNew(leftLine.scaleToNew(extensionLeft)); right = endRight.addNew(rightLine.scaleToNew(extensionRight)); } return Triangle.fromCorners(start, left, right); } private  AngleRaterMath(); static ITriangle getTriangle(final IVector2 endLeft, final IVector2 endRight, final boolean extend,
			final IVector2 start);  }