Given the following equations:
$$a=\frac{py+qx}{2pq}$$ $$b=\frac{py-qx}{2pq}$$
Where p and q are some real constant number. And $(x, y)$ are some arbitrary real number. Any number can be inputted as $(x, y)$ but only those which produce whole integers for $a$ and $b$ respectively, are considered valid. Given these conditions, how can I find the valid $(x_1, y_1)$ values whose euclidean distance to the inputted $(x, y)$ is minimal?
E.g. for clarification. Given $p=1.6$ and $q=0.8$. The user inputs $(x,y) = (0, 1.5)$. This produces $(a,b)=(0.9375,0.9375)$ as this is not an integer value it is not considered valid. The next closest input which would produce an integer would be (0, 1.6). We'll call this $(x1,y1) = (0,1.6)$. Given the user inputs $(x,y)$ how can I return the closest valid position of $(x1,y1)$?.
This is a follow-up question with better clarifcation from the previous one here.