I need to get the angle between two vector3 points, how would I go about doing it?
✓ ANSWER ACCEPTED
Getting angle between two vector3's?
2 answers
✓ Accepted answer
We can use the fact that the dot product of two vectors has two equivalent definitions.
The first definition is the sum of the products of the components, and ROBLOX provides this for you: If a and b are vectors, then the dot product of a and b is a:Dot(b).
The second definition is the product of the vectors' magnitudes and the cosine of the angle between them. So we have some simple algebra here:
-- Let a and b be vectors and d be the dot-product of them.
-- t is the angle for which we are solving, and |u| is taken to mean the
-- magnitude of u (in ROBLOX, u.magnitude)
-- |a| * |b| * cos(?) = d
-- cos(t) = d / (|a| * |b|)
-- t = arccos(d / (|a| * |b|))
-- To clean this math up further, we can make a and b be
-- unit vectors, so that their magnitudes are one and don't matter.
-- cos(t) = d
-- t = arccos(d)
-- So here it is in Lua.
-- a and b are the unit vectors
local theta = math.acos( a.unit:Dot(b.unit) );
-- theta is now the angle between a and b, measured in radians.
BlueTaslem really knows what he's doing. I don't understand dot points, however. Doesn't it take 3 points/ 2 intersecting lines to make an angle?
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You can interpret vectors are lines coming out of the origin. So you have three points: the origin, and the endpoint of each vector-arrow.