Theory of X-Ray Diffraction