Vector2 clampLength(double min, double max) { var length = this.length(); return divideScalar(length) .multiplyScalar(Math.max(min, Math.min(max, length))); }