Artificial intelligent assistant

A point in a matrix subdvided in x pieces, how to know which piece is the point? Note: I am developing a algorithm for CUDA. My question is: I have a matrix of size N*N, and I will subdivide it in N pieces, like the image: !subdivided and given a random point, how can I know which one of the N pieces the point is? I am assuming that N is power of 2 to make it easier, but since it is not a fixed number, I am having no idea how to...

I think this is a very strange way to partition a matrix, however if it must be this way then I would let $(x,y)$ be the random point, determine the angle $\theta = atan2(y,x)$ that this point makes from the positive $x$ axis, and use that to determine which section it is in. This is a natural way considering that your partitioning is defined by angles about the origin.

You've drawn your particular problem with the first region starting at $\frac{3 \pi}{4}$. Following that, the solution for $n$ sections is as follows:

Start with calculating
$$\theta = \text{atan2}(x,y)$$ Then your answer is $$ \left\lceil \frac{\theta + \frac{\pi}{4}}{\frac{2 \pi}{n}} \right\rceil $$ This will give you the secion that your point is in with the first being $1$. If you want to start with the first being $0$, then you use floor instead of cieling.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 72869ddf7a543d61bfe7c3cfcfcb72ee