In one dimension the derivative of $\operatorname{rect}_{L_x}(x)$ is given by:
$\partial_{x} \operatorname{rect}_{L_x}(x) = \delta(x+L_x/2) - \delta(x-L_x/2)$
Now I have a scalar field defined by $\operatorname{rect}$ function (rectangle distribution or potential in $x,y$ plane) of $(L_x,L_y)$ lengths:
$f(x,y) = \operatorname{rect}_{L_x} (x) \operatorname{rect}_{L_y} (y)$
I rotate the scalar field of an angle $\alpha$, that gives (in principle):
$f_{\alpha}(x,y) = \operatorname{rect}_{L_x} (\cos \alpha x + \sin \alpha y) \operatorname{rect}_{L_y} (\cos \alpha y - \sin \alpha x)$
And now I want to calculate the gradient of this function so I have:
$\vec{\nabla} f_{\alpha}(x,y) = \partial_{x} f_{\alpha}(x,y) \vec{e_x} + \partial_{y} f_{\alpha}(x,y) \vec{e_y}$
If we take just the $\vec{e_x}$ term we have, using product rule:
$\partial_{x} f_{\alpha}(x,y) = \operatorname{rect}_{L_y} (\cos \alpha y - \sin \alpha x) \partial_{x} \operatorname{rect}_{L_x} (\cos \alpha x + \sin \alpha y) + \operatorname{rect}_{L_x} (\cos \alpha x + \sin \alpha y) \partial_{x} \operatorname{rect}_{L_y} (\cos \alpha y - \sin \alpha x)$
What is the result of this partial derivative?
I would say, but I do not really know:
$\partial_{x} \operatorname{rect}_{L_x} (\cos \alpha x + \sin \alpha y) \stackrel{?}{=} \cos \alpha \left[ \delta(\cos \alpha x + \sin \alpha y + L_x/2) - \delta(\cos \alpha x + \sin \alpha y - L_x/2) \right]$
but that seems wrong because of the rotation. Thank you for your help!
I think that you are close to correct. This is what I get: $$\begin{align} f_\alpha(x,y) &= \operatorname{rect}_{L_x}(x\cos\alpha+y\sin\alpha) \operatorname{rect}_{L_y}(-x\sin\alpha+y\cos\alpha) \\ \\ \partial_x f_\alpha(x,y) &= (\delta_{-L_x/2}(x\cos\alpha+y\sin\alpha)-\delta_{+L_x/2}(x\cos\alpha+y\sin\alpha))\cos\alpha \\&\quad\quad\cdot \operatorname{rect}_{L_y}(-x\sin\alpha+y\cos\alpha) \\ &+ \operatorname{rect}_{L_x}(x\cos\alpha+y\sin\alpha) \\&\quad\quad\cdot (\delta_{-L_y/2}(-x\sin\alpha+y\cos\alpha) - \delta_{+L_y/2}(-x\sin\alpha+y\cos\alpha)) (-\sin\alpha) \\ \partial_y f_\alpha(x,y) &= (\delta_{-L_x/2}(x\cos\alpha+y\sin\alpha)-\delta_{+L_x/2}(x\cos\alpha+y\sin\alpha))\sin\alpha \\&\quad\quad\cdot \operatorname{rect}(-x\sin\alpha+y\cos\alpha) \\ &+ \operatorname{rect}(x\cos\alpha+y\sin\alpha) \\&\quad\quad\cdot (\delta_{-L_y/2}(-x\sin\alpha+y\cos\alpha) - \delta_{+L_y/2}(-x\sin\alpha+y\cos\alpha)) \cos\alpha \end{align}$$