change halfWidth and halfHeight to L, add ArithmeticException