normalize method

V4 normalize()

Returns a normalized (unit-length) copy of this vector.

If length is zero, treats it as 1 to avoid division by zero.

Implementation

V4 normalize() {
  double length = this.length;
  if (length == 0.0) length = 1.0;
  final ilength = 1.0/length;
  return _v4(
    x*ilength,
    y*ilength,
    z*ilength,
    w*ilength,
  );
}