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



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.SquaredMagnitude(vector)
	return vector.X^2+vector.Y^2+vector.Z^2
end


return VectorUtil
