AncienT

getAngleBetweenPoints3D

Recommended Posts

How can I get the angle between 2 positions?

Share this post


Link to post

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

Share this post


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

Share this post


Link to post

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

Share this post


Link to post

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.

Share this post


Link to post

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.