Jump to content

getAngleBetweenPoints3D


AncienT

Recommended Posts

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
Link to comment

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.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...