normalized method

Vector2 normalized()
inherited

Normalized copy of this.

Implementation

Vector2 normalized() {
  final length = this.length;
  if (length == 0) return .new(x, y);

  final scale = 1 / length;
  return .new(x * scale, y * scale);
}