clampScalar method

Vector3 clampScalar(
  1. double minVal,
  2. double maxVal
)

If this vector's x, y or z values are greater than the max value, they are replaced by the max value.

If this vector's x, y or z values are less than the min value, they are replaced by the min value.

  • min - the minimum value the components will be clamped to
  • max - the maximum value the components will be clamped to

Implementation

Vector3 clampScalar(double minVal, double maxVal) {
  x = math.max(minVal, math.min(maxVal, x));
  y = math.max(minVal, math.min(maxVal, y));
  z = math.max(minVal, math.min(maxVal, z));

  return this;
}