Circular Movement (contd.)

So I’ve been working it out and here’s what I’ve gotten:

[lua]img.Think = function()
local frx, fry = frame:GetPos()
local x,y = gui.MousePos()
x = x - frx
y = y - fry

if math.abs(x - lastx) + math.abs(y - lasty) > 5 and ( x - frame:GetWide()/2 ) ^ 2 + ( y - (frame:GetTall() - img:GetTall()/2 - 25) ) ^ 2 <= ( ( 175 / 2) / 2 ) ^ 2 then
hook.Call(“MouseChanged”,nil,x-lastx,y-lasty)
end

lastx,lasty = x,y
end[/lua]

It may seem like a lot of fancy math, but that’s irrelevant. The point is, it detects movement well enough to make sure that it works.

However, my question is how do you detect whether the movement is clockwise or counterclockwise? It wouldn’t be enough to consider whether x + y is positive or negative, because it can be either and go either clockwise or counterclockwise.

I understand this is a difficult question (for me at least), and I would greatly appreciate any help I can get.

For the few of you going “wtf is this”,

You could divide the wheel up into a few sections, and save the mouse position every x frames or seconds, and based on what direction the mouse has changed in, and what section its in, you can calculate which direction on the wheel it’s going.

Say you had 4 sections, so the wheel was divided in an X. Take the 2 “snapshots” of the mouse position, then check what section it was in (based on the position). If the x value is larger, and it’s in the top section, at that moment it’s going clockwise. You can even speed up and slow down based on how far apart the snapshots are.

Untested, didn’t read your last thread, but wouldn’t this be a bit more convenient for circular movement?

[lua]local frx, fry = frame:GetPos()
frx, fry = frx + frame:GetWide()/2, fry + frame:GetTall()/2
x, y = x - frx, y - fry

local ang = math.deg(math.atan2(y, x))
– do stuff with that angle

lastang = ang[/lua]

thank you for the example of how to use atan2 this function always confused me.