Diffraction, discovered in 1912, is at the origin of x-ray crystallography. It is an interference effect. The incident x-ray beam can be considered as an electromagnetic wave. The wavelength λ is the distance between two consecutive wave crests. Diffraction occurs when atoms in adjacent crystal planes, separated by a distance d, scatter the incident x-ray beam such that the emerging waves add together constructively. In other words, the emerging waves scattered from the adjacent crystal planes are in phase. This requires that the difference in optical path length for x-rays scattered from the adjacent planes be an integral number of wavelengths. The difference in path length is 2 d sin θ, where θ is the angle of incidence. This leads to Bragg's law, which describes the condition on θ for the constructive interference to be at its strongest.
2 d sin θ = n λ
A diffraction pattern is obtained by measuring the intensity of scattered waves as a function of scattering angle. Very strong intensities known as Bragg peaks are obtained in the diffraction pattern at the points where the scattering angles satisfy the Bragg condition.
Diffraction can be used to measure strains in materials under external stimuli (e.g. temperature, magnetic field, electric field) by monitoring changes in the spacing of atomic planes.