Vector2 clampScalar(double minVal, double maxVal) { x = Math.max(minVal, Math.min(maxVal, x)); y = Math.max(minVal, Math.min(maxVal, y)); return this; }