Transform this matrix of distances into a more general one I need to make the navigation and guidance of a vehicle (a quadcopter) in a platform. This platform can be seen like this:

where the blue dots are the center of each square, and the $x$ distances are all the same, and the $y$ distances are all the same.
I need the distance between each blue dot to the center (the blue dot of the $(2;2)$), but that distance depends on the $yaw$ angle. For example, if $yaw=0^\circ$, the situation is like this:

and the distances are:
$$d_{1;1} = (-d_x; -d_y)$$
$$d_{1;2} = (-d_x; 0)$$
$$d_{1;3} = (-d_x; d_y)$$
$$d_{2;1} = (0; -d_y)$$
$$d_{2;2} = (0; 0)$$
$$d_{2;3} = (0; d_y)$$
$$d_{3;1} = (d_x; -d_y)$$
$$d_{3;2} = (d_x; 0)$$
$$d_{3;3} = (d_x; d_y)$$
If the situation is with $yaw=180^\circ$:

the distances are the same but with the opposite sign, i.e,
$$d_{1;1} = (d_x; d_y)$$
$$d_{1;2} = (d_x; 0)$$
$$d_{1;3} = (d_x; -d_y)$$
$$d_{2;1} = (0; d_y)$$
$$d_{2;2} = (0; 0)$$
$$d_{2;3} = (0; -d_y)$$
$$d_{3;1} = (-d_x; d_y)$$
$$d_{3;2} = (-d_x; 0)$$
$$d_{3;3} = (-d_x; -d_y)$$
If $yaw=90^\circ$, the situation is like this:

and the distances (see the difference between $d_x$ and $d_y$) would be:
$$d_{1;1} = (-d_y; d_x)$$
$$d_{1;2} = (-d_y; 0)$$
$$d_{1;3} = (-d_y; d_x)$$
$$d_{2;1} = (0; -d_x)$$
$$d_{2;2} = (0; 0)$$
$$d_{2;3} = (0; d_x)$$
$$d_{3;1} = (d_y; -d_x)$$
$$d_{3;2} = (d_y; 0)$$
$$d_{3;3} = (d_y; d_x)$$
If $yaw = -90^\circ$:

the distances would be:
$$d_{1;1} = (d_y; d_x)$$
$$d_{1;2} = (d_y; 0)$$
$$d_{1;3} = (d_y; -d_x)$$
$$d_{2;1} = (0; d_x)$$
$$d_{2;2} = (0; 0)$$
$$d_{2;3} = (0; -d_x)$$
$$d_{3;1} = (-d_y; d_x)$$
$$d_{3;2} = (-d_y; 0)$$
$$d_{3;3} = (-d_y; -d_x)$$
I need to write a matrix that uses the information of the $yaw$ angle and returns the distances from each angle (not just 0, 90, -90 and 180, but also 1, 2, 3, ...)
I tried to write it but I couldn't find the solution.
Thank you very much. I really need this help
Edit: please note that the coordinate frame moves with the quadcopter, like in this image:

Edit 2: for example, if $yaw=45^\circ$, then the distance from $(3;3)$ to $(2;2)$ is $\sqrt{d_x^2+d_y^2}$ in $x$ and $0$ in $y$.
 A: This is more of a comment than an answer, but since it will take some space, writing it here.
I think you are asking about "directed distance" or a "vector" from the point $(2,2)$ to each of the other points.  Depending on what your coordinate axes are, the vectors each undergo a rotation.  
I am not sure why, in the canonical form (your first example) you've defined $x$ to be up and $y$ to the left.  That's okay, as long as you are consistent.  But then, why is $d_{1,1}=-(d_y,d_x)$?  Are you defining the directed distance from $(1,1)$ to $(2,2)$.  Seems that $(2,2)$ is the origin of your coordinate system.  We usually define vectors or directed distances from the origin to another point.  In any case, once you settle on a meaningful coordinate system, any rotation in the axes can be coded (calculated) by multiplying each vector by a rotation matrix.
$$R=\begin{pmatrix} \phantom{-} \cos \varphi& \sin \varphi\\ -\sin\varphi & \cos \varphi \end{pmatrix},$$ being careful to define $\phi$ appropriately as the angle of rotation from one of the coordinate axes.  Depending on whether you are defining the rotation of the axes, or the rotation of the vector (and how you define all of the above), that minus sign might be better placed with the other $\sin \phi$.  A simple way to check if you have it correct is to compute the resulting vectors for some special case, for example $\varphi=30^\circ.$
A: There is a simple pythagorean formula for the distance of a lattice point $(j,k)$ from the center $(j_c, k_c)$ of the rectangular lattice, namely
$$d(j,k)=\sqrt{(j-j_c)^2 dx^2 +(k-k_c)^2 dy^2}\ .$$
In the case at hand $(j_c,k_c)=(2,2)$, but in a general case $j_c$, $k_c$ might be half integer numbers.
One does not have to deal with the "yaw angles" or the (unknown) polar angles of the displacement vectors in question. But maybe your problem is completely different, and you have not yet clearly formulated it.
A: If the $(\textrm{row} ; \textrm{column})$ label of the reference point is $(a_0; b_0)$ (in our case this is $(2; 2)$), then with respect to the standard basis (not the one depending on the yaw of the quadcopter) the displacement of that point from the one with the label $(a; b)$ is $${\bf s} := (d_x(a_0 - a), d_y(b_0 - b)) .$$ The problem is writing this displacement with respect to the coordinate frame basis defined by the quadcopter's current orientation.
Let $\theta$ denote the yaw of the quadcopter. As in the question statement we declare that the facing north is $\theta = 0$ and that increasing yaw correspondings to anticlockwise rotation. Then, by definition, the coordinate frame basis (written in terms of the standard basis) is
$$({\bf x}, {\bf y}) = ((-\sin \theta, \cos \theta), (-\cos \theta, -\sin \theta)) .$$
Since this basis is orthonormal, the representation of the displacement vector ${\bf s}$ with respect to this basis is $$({\bf s} \cdot {\bf x}, {\bf s} \cdot {\bf y}) .$$
For example, the first component is
$$
{\bf s} \cdot {\bf x}
= (d_x(a_0 - a), d_y(b_0 - b)) \cdot (-\sin \theta, \cos \theta)
= d_x(a - a_0) \sin \theta - d_y(b - b_0) \cos \theta .
$$
Notice that this formula shows that using the convention $(a_0; b_0) = (0; 0)$ would be especially convenient, as the formula then simplifies to
$$
{\bf s} \cdot {\bf x}
= d_x a \sin \theta - d_y b \cos \theta .
$$

Example For the setup in the question, we carry out part of the computation in the case that the spacing is given by $d_x = 1, d_y = 2$ and the yaw is $20^\circ$. We find the components of displacement vector from the point with row/column label $(a; b) = (1; 1)$ to the reference point, which has label $(a_0; b_0) = (2; 2)$.
Substituting in the formula for $\bf s$ gives that the displacement vector (with respect to the standard basis) is ${\bf s} = (1, 2)$. The coordinate frame basis (written with respect to the standard basis) is $({\bf x}, {\bf y}) = ((-\sin 20^\circ, \cos 20^\circ), (-\cos 20^\circ, -\sin 20^\circ))$, so, for example, the component of $\bf s$ in the $\bf x$-direction is
$${\bf s} \cdot {\bf x} = (1, 2) \cdot (-\sin 30^\circ, \cos 30^\circ) = -\sin 20^\circ + 2 \cos 20^\circ \approx 1.53736 .$$
The computation for the component in the ${\bf y}$-direction is similar.
