# mouse pointer finder?

• July 27th, 2013, 02:55 PM
xchan
mouse pointer finder?
Attachment 2215

how can i put it this way,
if the mouse pointer is in the orange region, it will give me 0;
if the mouse pointer is in green region, it will give me 1;
in red is 2;
in violet is 3;

just a simple top, right, bottom, left;

i cant make an equation or formula :/

• July 27th, 2013, 03:38 PM
jps
Re: mouse pointer finder?
Where are you stuck? What did you try?
How would you do it if the given shape was drawn on graph paper?
Each region has some relation to it's position and the x,y values
Post the code for better help, there are too many unknowns in the given problem.
• July 27th, 2013, 03:42 PM
xchan
Re: mouse pointer finder?
i cant put codes because there's no codes yet at all..

i think my question is not clear..

how will i know if the mouse pointer is (45 degrees to 135 degrees) to the center, or exactly where orange region is... there is sin or cosine involved here and i cant do it
• July 27th, 2013, 03:52 PM
jps
Re: mouse pointer finder?
• July 27th, 2013, 04:46 PM
xchan
Re: mouse pointer finder?
ok thanks for that info but how can i convert the angle between my mouse pointer and the center of the jframe to raidans?
• July 27th, 2013, 05:24 PM
jps
Re: mouse pointer finder?
How would you do it without a computer or program?
If you do not understand rotation in radians, tackle this problem in a way that you understand. There are multiple ways to determine which area the mouse is in.
How would you do it on graph paper?
If the mouse is above the middle or below the middle would give you the upper half or lower half... Now you have cut out one possible option, either the top or bottom.
If the mouse is to the left of center or right of center... Now you cut out either the left or right side leaving only two possible options.
The only thing left to do is determine which side of the diagonal line the mouse is in, because in all possible cases you are left with a square 1/4 the original size cut in half corner to corner