truncate static method

Vector3 truncate(
  1. Vector3 vector,
  2. double max
)

Clamps the magnitude of vector to max.

Implementation

static vm.Vector3 truncate(vm.Vector3 vector, double max) {
  if (vector.length2 > max * max) {
    return vector.normalized() * max;
  }
  return vector;
}