normalize method

double normalize()

Normalizes this. Returns the length of the vector before normalization.

Implementation

double normalize() {
  final length = this.length;
  if (length == 0) {
    return 0;
  }

  final scale = 1 / length;
  x *= scale;
  y *= scale;
  z *= scale;
  return length;
}