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).
Re: Grid System
If the pointer is at (x, y), then it is over th cell from the left and th cell from the top. Here is the floor function. In a programming language, you may use integer division instead of floating-point division and rounding.