I’m making this function to calculate the internal angle of three points:
function InternalAngle<T>(p1: T, p2: T, p3: T): number
-- https://youtu.be/vUQo7HVCx8A
local p1p2 = p2 - p1
local p1p3 = p3 - p1
return math.acos(p1p2:Dot(p1p3) / (p1p2.Magnitude * p1p2.Magnitude))
end
However, luau is complaining that Type 'T' could not be converted into 'number'
.
How do I make it clear that T must be either a Vector2
or a Vector3
?