[Solved] Getting the angle between two frames inside of the player screen

Getting back to this approach:

You don’t need to mess with screen size to compare which quadrant a point is in.
Given point (x,y) and the center of your center frame being (0,0):

if x > 0 and y > 0 then
    --Q1
elseif x < 0 and y > 0 then
    --Q2
elseif x < 0 and y < 0 then
    --Q3
elseif x > 0 and y < 0 then
    --Q4
end

Replace < and > with <= and >= depending on which case you want to happen on which edge. To have the inner frame as the origin, do (x,y):=(x2-x1,y2-x1) where (x2,y2) is the inner frame and (x1,y2) is the outer frame.

My code for angles solution:

local f1 = gui.Frame1
local f2 = gui.Frame2
while wait() do
    print(-math.deg(math.atan2(f2.AbsolutePosition.X - f1.AbsolutePosition.X, f2.AbsolutePosition.Y - f1.AbsolutePosition.Y) - math.pi))
end
2 Likes

Right, and if the quadrants are rotated 45 degrees then the comparisons need to be done with the absolute ratio of x and y as I described above.

Are the quadrants like this:
image
or like this:
image

They are diamond shaped, I just rotated them to show you what happened to the angles.

If the center frame is unrotated, no problem, the solution works fine.

For a rotated frame (and therefore rotated quadrants) it’s still easier to just rotate the coordinate system.

local t = -math.pi/2 -- -45°
x = x*cos(t)-y*sin(t)
y = y*cos(t)+x*sin(t)

The one you selected above works just fine, thanks.