Results 1 to 2 of 2

Thread: Grid System

  1. #1
    Senior Member vaironxxrd's Avatar
    Nov 2010

    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.

    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
    Oct 2009

    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: Jan 30th 2010, 02:06 PM
  2. Ten by Ten grid
    Posted in the Discrete Math Forum
    Replies: 3
    Last Post: Nov 2nd 2009, 02:50 PM
  3. nxn grid problem.
    Posted in the Math Topics Forum
    Replies: 4
    Last Post: Oct 31st 2009, 07:00 AM
  4. grid of stairs
    Posted in the Algebra Forum
    Replies: 11
    Last Post: Aug 13th 2009, 05:55 AM
  5. Help With A Grid
    Posted in the Pre-Calculus Forum
    Replies: 2
    Last Post: Oct 31st 2008, 12:34 PM

Search Tags

/mathhelpforum @mathhelpforum