How to find full 360 degree angle between 3 points

Hello!

I’m trying to find the full 360 degree angle between 3 points. I found this formula in another post which tells me the angle between my 3 points but when the angle goes over 180 it starts lowering afterwards. I know why this is happening but I can’t seem to find out how to fix it since I’m not a galaxy brain mathematician.

Here’s the formula:

local A = workspace.A

local B = workspace.B

local C = workspace.C

local BA = (A.Position - B.Position).Unit

local BC = (C.Position - B.Position).Unit

local angle = math.acos(BA:Dot(BC))

print(angle)

Here’s a diagram of my problem:
What works fine:


What I don’t want:

What I Want:

Would be useful to know what your usecase for this is

you can just do 360 - 170 to get 190
like if you take the top point as A and the middle one as B

if A.Position.X > B.Position.X then
Angle = Angle
else
Angle = 360 - Angle
end

Maybe this helps? Get the angle between 2 parts parallel to the ground on X axis

The formula you found gives the “minimum” angle between the lines formed by your points. In order to create a distinction between, say, 90 and -90, you need additional information which you can add by taking the cross product.

However for this to work you must have a defined “up” direction around which angles are assumed to be measured around. This will be the case if your points are always on the same plane, or can be projected on to the same plane. For example, if your points have a height along the Y-axis, but you don’t care what it is, and you want two points with the same X and Z coordinates to behave the same, then you also meet this requirement.

Does this line up with what you want? If so let me know and I will explain cross product method in more detail.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.