I have a 2D grid for which the origin can offset by X,Y and has a rotation (the whole grid is rotated). The grid has a "grid size" parameter defining the size of any square in the grid.
On the grid I project a target point Px, Py and I need to find the closest intersection (or the center of the grid square the point is on) on that grid.
Imagine a "snap to grid" algorithm where the grid can be translated and rotated.
As of now, I can "snap to grid" with a simple algorithm that rounds the position of the point on the grid and plops back the offset but it only works when the grid is perfectly flat (with no rotation).
Any pointers would be much appreciated
On the grid I project a target point Px, Py and I need to find the closest intersection (or the center of the grid square the point is on) on that grid.
Imagine a "snap to grid" algorithm where the grid can be translated and rotated.
As of now, I can "snap to grid" with a simple algorithm that rounds the position of the point on the grid and plops back the offset but it only works when the grid is perfectly flat (with no rotation).
Any pointers would be much appreciated