local r={}function r.ClampMagnitude(r,m)return r.Magnitude>m and r.Unit*m or r end function r.AngleBetween(r,m)return math.acos(math.clamp(r.Unit:Dot(m.Unit),-1,1))end function r.AngleBetweenSigned(m,x,L)local s=r.AngleBetween(m,x)return s*math.sign(L:Dot(m:Cross(x)))end function r.AngleBetweenSigned(m,x,L)local s=r.AngleBetween(m,x)return s*math.sign(L:Dot(m:Cross(x)))end function r.SquaredMagnitude(r)return(r.X^2+r.Y^2)+r.Z^2 end return r



local VectorUtil = {}


function VectorUtil.ClampMagnitude(vector, maxMagnitude)
	return (vector.Magnitude > maxMagnitude and (vector.Unit * maxMagnitude) or vector)
end


function VectorUtil.AngleBetween(vector1, vector2)
	return math.acos(math.clamp(vector1.Unit:Dot(vector2.Unit), -1, 1))
end


function VectorUtil.AngleBetweenSigned(vector1, vector2, axisVector)
	local angle = VectorUtil.AngleBetween(vector1, vector2)
	return angle * math.sign(axisVector:Dot(vector1:Cross(vector2)))
end

function VectorUtil.AngleBetweenSigned(vector1, vector2, axisVector)
	local angle = VectorUtil.AngleBetween(vector1, vector2)
	return angle * math.sign(axisVector:Dot(vector1:Cross(vector2)))
end

function VectorUtil.SquaredMagnitude(vector)
	return vector.X^2+vector.Y^2+vector.Z^2
end


return VectorUtil
