normalize method

Q normalize()

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

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

Implementation

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