Results 1 to 2 of 2

Math Help - Grid System

  1. #1
    Senior Member vaironxxrd's Avatar
    Joined
    Nov 2010
    From
    USA
    Posts
    424
    Thanks
    1
    Awards
    1

    Grid System

    I'm making a grid system using computer science.

    My idea is that when the mouse pointer is hovering a cell of the grid that cell should be highlighted. But, I'm having a bit of trouble.

    Problem:
    Lets say for simplicity a cell is 5 x 5 so half of the cell is 2.5. If the mouse is hovering at a position of 3,3 or even 1.5,3.
    How can I make a mathematical formula which finds the origin of the cell which I'm hovering.

    Finding the points at which the cell is being drawn, look at the picture for more detail (hopefully).

    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Joined
    Oct 2009
    Posts
    5,517
    Thanks
    771

    Re: Grid System

    If the pointer is at (x, y), then it is over \lfloor x / 5\rfloorth cell from the left and \lfloor y / 5\rfloorth cell from the top. Here \lfloor\cdot\rfloor is the floor function. In a programming language, you may use integer division instead of floating-point division and rounding.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. grid generation
    Posted in the Math Software Forum
    Replies: 1
    Last Post: January 30th 2010, 02:06 PM
  2. Ten by Ten grid
    Posted in the Discrete Math Forum
    Replies: 3
    Last Post: November 2nd 2009, 02:50 PM
  3. nxn grid problem.
    Posted in the Math Topics Forum
    Replies: 4
    Last Post: October 31st 2009, 07:00 AM
  4. grid of stairs
    Posted in the Algebra Forum
    Replies: 11
    Last Post: August 13th 2009, 05:55 AM
  5. Help With A Grid
    Posted in the Pre-Calculus Forum
    Replies: 2
    Last Post: October 31st 2008, 12:34 PM

Search Tags


/mathhelpforum @mathhelpforum