lib/vector2.rb
# Sets this vector's magnitude to 1.
Sets this vector's magnitude to 1.
Sets this vector ' s magnitude to 1 .
def unit!
    raise "can't modify frozen object" if frozen?
    scale = 1/magnitude
    @x, @y = @x * scale, @y * scale
    @hash = nil
    self
  end
def unit! raise "can't modify frozen object" if frozen? scale = 1 / magnitude @x , @y = @x * scale , @y * scale @hash = nil self end
Sets this vector's magnitude to 1.
Sets this vector ' s magnitude to 1 .