clampLength method
Clamps the length of this vector.
This means that if the length is less than min
the length will be set to
min
and if the length is larger than max
, the length will be set to
max
. If the length is in between min
and max
, no changes will be
made.
Implementation
void clampLength(double min, double max) {
final lengthSquared = length2;
if (lengthSquared > max * max) {
scaleTo(max);
} else if (lengthSquared < min * min) {
scaleTo(min);
}
}