
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).
http://img33.imageshack.us/img33/3847/gridsystem.jpg

Re: Grid System
If the pointer is at (x, y), then it is over $\displaystyle \lfloor x / 5\rfloor$th cell from the left and $\displaystyle \lfloor y / 5\rfloor$th cell from the top. Here $\displaystyle \lfloor\cdot\rfloor$ is the floor function. In a programming language, you may use integer division instead of floatingpoint division and rounding.