limit method

PVector limit(
  1. double max
)

( begin auto-generated from PVector_limit.xml )

Limit the magnitude of this vector to the value used for the max parameter.

( end auto-generated )

@webref pvector:method @usage web_application @param max the maximum magnitude for the vector @brief Limit the magnitude of the vector

Implementation

PVector limit(double max) {
  if (magSq() > max * max) {
    normalize();
    mult(max);
  }
  return this;
}