class 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();

}