--!native --!optimize 2 -- Compiled with roblox-ts v3.0.0 local Vector2Tools = {} do local _container = Vector2Tools local sin = math.sin local cos = math.cos local min = math.min local max = math.max local clamp = math.clamp local function Rotate(vector, angle) local angle_sin = sin(angle) local angle_cos = cos(angle) return Vector2.new(vector.X * angle_cos - vector.Y * angle_sin, vector.X * angle_sin + vector.Y * angle_cos) end _container.Rotate = Rotate local function LerpWithMagnitude(start_vector, target_vector, step) local _target_vector = target_vector local _start_vector = start_vector local difference = _target_vector - _start_vector --if difference is 0 return the target; if difference.Magnitude == 0 then return target_vector end step = min(difference.Magnitude, step) --add difference with magnitude of step; local _start_vector_1 = start_vector local _unit = difference.Unit local _step = step return _start_vector_1 + (_unit * _step) end _container.LerpWithMagnitude = LerpWithMagnitude local function Clamp(vector, min, max) return Vector2.new(clamp(vector.X, min, max), clamp(vector.Y, min, max)) end _container.Clamp = Clamp local function ClampWithVector(vector, min_vector, max_vector) return Vector2.new(clamp(vector.X, min_vector.X, max_vector.X), clamp(vector.Y, min_vector.Y, max_vector.Y)) end _container.ClampWithVector = ClampWithVector local function SubtractMagnitude(vector, amount, clamp_to_zero) if clamp_to_zero == nil then clamp_to_zero = false end local new_magnitude = vector.Magnitude - amount --if less then 0, clamps; if clamp_to_zero then new_magnitude = max(new_magnitude, 0) end --sets new magnitude; local _unit = vector.Unit local _new_magnitude = new_magnitude return _unit * _new_magnitude end _container.SubtractMagnitude = SubtractMagnitude end return { Vector2Tools = Vector2Tools, }