AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Neeed help detecting what side of a box cursor crossed

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
V@no



Joined: 13 Sep 2007
Posts: 37

PostPosted: Sun Mar 23, 2008 10:34 pm    Post subject: Neeed help detecting what side of a box cursor crossed Reply with quote

Hello!
I'm trying figure out a way to detect which side of a rectangular box cursor crossed and at which coordinate.
The problem I have is that cursor doesn't move one pixel at a time, depends on the mouse speed it jumping, so, by the time it "entered" the box I get coordinates on opposite side of the box it entered from...
The way I could think to solve this is to draw imaginary line from last coordinate before it crossed a box's side to the coordinate within the box.
Now here comes the hard part that I need help with: how to do that line? or perhaps there is another or even simpler way to get that coordinate?

Thank you!


Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Sun Mar 23, 2008 11:30 pm    Post subject: Reply with quote

Code:
y = mx+c


take start x and start y
take finish x and finish y

create a quadratic equation:

Code:
y1-mx1 = y2-mx2


to get m, and then substitute in to get c. you now have the gradient of your line.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group