Vector3 to unit vector

I might be being dumb but I want to Dot two Vector3’s then put them into a acos, but how would I make the Vector3’s into unit vectors so that I could get an acos that isnt nan

Vector3.Unit normalises any vector, but what you’re looking for is this:

-- canonical method for obtaining the angle between two normals
local function angle(v1, v2)
  return math.acos(math.clamp(v1.Unit:Dot(v2.Unit), -1, 1))
end
1 Like

You can remove the math.clamp in this, the dot product of two unit vectors will always be in that range automatically.

2 Likes