CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 20

Threaded View

  1. #1
    Join Date
    May 2007
    Posts
    3

    Question Most efficient way to determine in what quadrant coordinates fall

    Hello All,

    A (possibly) quick logic problem:

    In a program I'm writing I've divided my monitor into 25 different quadrants.
    Sort of like this:
    ___________________
    [1] [2 ]___3_____[4][5 ]
    [6] [7 ]___8_____[9][10]
    | . | . |
    | . | . |
    | . | . |
    | . | . |
    |11|12| 13
    | . | . |
    | . | . |________[14][15]
    [16][17]__18___[19][20]
    [21][22]__23___[24][25]

    [Edit: Sorry about the image. The formatting was terrible when I posted it. Basically, the right side should look like the left. [13] is the area in the center and [14][15] are the equivalent of [11][12]. Thanks. ]



    Let's say that each of the lines of the quadrants fall at 100 and 200 pixels from the edge of my screen and the dimensions of my screen in pixels are:

    0------->xdim
    |
    |
    |
    |
    |
    |
    ydim

    My program knows the x and y coordinates in pixels of each mouse click.

    Does anyone know the most efficent way to find into which quadrant a mouse click falls?


    I'd really appreciate it if anyone has any ideas about this. I'm currently using numerous nested if/if else statements and greather than/less than comparisons. My code works, but clearly it is not very efficient and definitely ugly.


    Thank you very much,
    Ben
    Last edited by stang966; May 14th, 2007 at 02:40 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured