A beam of electrons accelerated through $54 V$ is directed normally at a nickel surface, and strong reflection is detected only at an angle of $50°$. Using the Bragg law, show that this implies a spacing $D$ of nickel atoms on the surface in agreement with known value $0.22$ nm.
I am having trouble understanding the geometry of the diagram below. What I know thus far is that the atoms in the crystal below form atomic planes in many different angles with respect to the surface which is why it is tilted at an angle in the picture below. What I don't understand is why does $\theta = 90 - \frac{\phi}{2}$? I know that $\theta$ is the angle at which constructive interference occurs but then why do we need $\phi$ for, what exactly is the difference between the two angles? $\phi$ in the diagram is $50$ degrees but shouldn't $\theta$ be $50$ degrees? Also, why does $D= \frac{d}{\sin\omega}$? I know Bragg's law is $2d\sin\theta = n\lambda$ but we have three different angles, $\omega, \theta$ and $\phi$ which is confusing me.

First, note the angle of incidence equals the angle of reflection. In your diagram, this is the angle $\theta$. Also in that diagram, the line labeled $\phi$ is perpendicular to the dotted lines. In particular, it splits the angle between the two red lines equally. Since that total angle is $\phi$, as it says in the diagram
each half-angle is thus $\frac{\phi}{2}$. Since the angle between the $\phi$ line and the dotted lines is $90^{\circ}$, this means
$$\theta + \frac{\phi}{2} = 90^{\circ} \implies \theta = 90^{\circ} - \frac{\phi}{2} \tag{1}\label{eq1A}$$
Since $\phi = 50^{\circ}$, this gives
$$\theta = 90^{\circ} - \frac{50}{2} = 65^{\circ} \tag{2}\label{eq2A}$$
Next, note the distance $d$ applies between the $2$ dotted lines, including up to the right side of the horizontal line segment marked as being of length $D$. Thus, if you draw a perpendicular line there, you would have a right-angled triangle, as indicated in the diagram above as $\triangle ABC$ where $\measuredangle ABC = 90^{\circ}$. As is often defined, $\sin$ is the opposite side length divided by the hypotenuse length, so you then have
$$\sin(\omega) = \frac{d}{D} \implies D = \frac{d}{\sin(\omega)} \tag{3}\label{eq3A}$$