class PenaltyArea implements IPenaltyArea {

	@Override
	@SuppressWarnings("squid:S1244") // equality check intended
	public IVector2 projectPointOnToPenaltyAreaBorder(final IVector2 point)
	{
		if (point.x() * Math.signum(getGoalCenter().x()) >= Math.abs(getGoalCenter().x()))
		{
			if (point.y() == 0.0)
			{
				return getGoalCenter().addNew(Vector2.fromX(getDepth()));
			}
			return getGoalCenter().addNew(Vector2.fromY(Math.signum(point.y()) * getLength() / 2));
		}
		return point.nearestToOpt(lineIntersections(Lines.lineFromPoints(point, getGoalCenter())))
				.orElseGet(() -> getGoalCenter().addNew(Vector2.fromX(getDepth())));
	}

	public  PenaltyArea(final IVector2 goalCenter, final double depth, final double length);

}