## Recommended Posts

`How can I get the angle between 2 positions?`

You should have three positions ( one of them is the reference ) in order to obtain an angle.

Posted (edited)
38 minutes ago, Simple0x47 said:

You should have three positions ( one of them is the reference ) in order to obtain an angle. ﻿

```i made this:
--FORMULA: cos(0)=a*b/|a||b|
local x1,y1,z1 = 4,-3,5
local x2,y2,z2 = 9,7,-10
local r1 = (x1*x2)+(-3*7)+(5*-10)
local a1 = x1^2+(-y1)^2+(z1)^2
local a2 = x2^2+(-y2)^2+(z2)^2
local r2 = math.sqrt(a1)-math.sqrt(a2)
local angle = r1/r2
print(angle)

I just do not know if it's the correct formula```
` `

Edited by AncienT

For what do you need the angle? Because you cannot get the angle of 3D points.

If you're looking for the Z rotation (bearing, yaw) between two points: findRotation. If you need the local Y (pitch) it can be computed in a similar way to findRotation. The local X (roll) rotation is not defined, so to speak, when looking towards another 3D position (i.e. it can be anything) unless you introduce some additional reference point perhaps.