X-ray diffraction is a phenomenon that can be used to help understand the structure of crystals. There are great writeups already on this topic. This writeup discusses the physical basis and gives the mathematical condition for x-ray diffraction. See also x-ray crystallography.

Suppose there is a system of two identical isolated atoms or molecules separated by a vector d. Now suppose that a plane wave (for our purposes an x-ray but this could be a neutron or electron too) is incident on the system, as shown below. The two atoms or molecules respond to the incident light by reradiating light in all directions. We will make the reasonable assumption that photon energy, and thus wavelength and wavevector magnitude, is conserved in the scattering process (i.e. the scattering is elastic). The question is, from what directions will we see waves scattered from the crystal?

           d / |            Reradiated wave
            /  | d.a        with wavevector k' = ka'
           /   | 
          |    |  
          |    |   
          |    |   
          |    |   
          |    |
          |    |
          |    |
       Incident plane wave with
       wavevector k = ka

Note: In the diagram, the 90-degree difference between incident and reradiated waves was chosen only to simplify the ASCII art. The vectors a and a' are arbitrary unit vectors. The points O correspond to atoms or molecules. The incident and reradiated waves have the same wavevector magnitude k. Also note how the tendency for us to want to draw from left to right gets in the way of logic.

For there to be constructive interference of the reradiated x-rays, the difference in the lengths of the paths travelled by the two incident waves must be an integer multiple of the wavelength.

The difference in the lengths of the paths is given by

d.a - d.a' = d.(a-a').

Setting the path difference equal to an integer n times the wavelength λ and using the fact that k = 2π/λ, the condition for constructive interference is

d.(k-k') = 2πn.

In a crystal there are identical scattering basis atoms at every point in the Bravais lattice. For there to be constructive interference from the radiation of all of the Bravais lattice sites, the condition for constructive interference must hold true when d is any Bravais lattice vector R. The constructive interference equation is equivalent to

ei(k-k').R = 1 for all R.

As mentioned in the writeup reciprocal lattice, the above holds true whenever (k-k') is some reciprocal lattice vector K. Noting that k and k' have the same magnitude and that if K is a reciprocal lattice vector then so is -K, we can write

k = |k - K|,

and after squaring both sides we get

k.K = K/2,

where K is the magnitude of a reciprocal lattice vector. The equation above defines Bragg planes! The geometrical method for constructing these planes is discussed in the writeup Brillouin zone.

The approach I followed above is called the Von Laue formulation. It turns out to be identical to the formulation done by Bragg, who showed that the condition for constructive interference can also be written as

nλ = 2dsinθ,

where d is the distance between two parallel planes of atoms in a crystal's real-space lattice and θ is the angle of incidence between the incident wave and a plane (not the normal to the plane).

Reference: Ashcroft/Mermin Solid State Physics