function get_angle(x1,y1,x2,y2)
angle = math.atan2(x1-x2,y1-y2)
return angle
end
--get_angle: Checks angle between any 2 joints [player1] [joint1] [player2] [joint2] around any axis [around: AROUND.X AROUND.Y AROUND.Z] and returns in degrees.
function get_angle(player1, joint1, player2, joint2, around)
local d1, d2
local j_pos1 = { }
local j_pos2 = { }
j_pos1['x'], j_pos1['y'], j_pos1['z'] = get_joint_pos(player1, joint1)
j_pos2['x'], j_pos2['y'], j_pos2['z'] = get_joint_pos(player2, joint2)
if around == AROUND.X then
d1 = j_pos2.z - j_pos1.z
d2 = j_pos2.y - j_pos1.y
end
if around == AROUND.Y then
d1 = j_pos2.z - j_pos1.z
d2 = j_pos2.x - j_pos1.x
end
if around == AROUND.Z then
d1 = j_pos2.y - j_pos1.y
d2 = j_pos2.x - j_pos1.x
end
local angle = math.deg( math.atan2(d1,d2) )
return angle
end