normalize method

V3 normalize()

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

Returns a copy of this vector unchanged if length is zero.

Implementation

V3 normalize() {
  final length = this.length;
  if (length != 0.0)
  {
    final ilength = 1.0/length;
    return _v3(
      x * ilength,
      y * ilength,
      z * ilength,
    );
  }

  return _v3(x, y, z);
}