Scripting Helpers is winding down operations and is now read-only. More info→

Log in to vote

1
I need to get the angle between two vector3 points, how would I go about doing it?

Log in to vote

4
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.

Log in to vote

0
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?

0

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. BlueTaslem 18071 — 6y

## Locked by theCJarmy7, Avigant, Programical, Thundermaker300, User#19524, User#1007, and Zafirua

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?