Grid Problem

Rupan

New member
Joined
Nov 16, 2016
Messages
1
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
 
:idea: Did you google anything like, "rotate xy coordinate system"? There exist trigonometric functions for calculating the new location of a point in a rotated plane.
 
Top