| View previous topic :: View next topic |
| Author |
Message |
V@no
Joined: 13 Sep 2007 Posts: 37
|
Posted: Sun Mar 23, 2008 10:34 pm Post subject: Neeed help detecting what side of a box cursor crossed |
|
|
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 |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1375
|
Posted: Sun Mar 23, 2008 11:30 pm Post subject: |
|
|
take start x and start y
take finish x and finish y
create a quadratic equation:
to get m, and then substitute in to get c. you now have the gradient of your line. |
|
| Back to top |
|
 |
|