When we use scattering radiation to probe critical phenomena, we have the usual Bragg relation for constructive interference $$|\vec{k}|=\frac{4\pi}{\lambda}sin\frac{\theta}{2}$$ where $\vec{k}$ is the change in wavevector after scattering, $\lambda$ is the wavelength of the radiation and $\theta$ is the angle of deflection.
The scattering intensity is taken to proportional to the Fourier transform of the real space correlation function $$I(\theta)\propto g(\vec{k})=\int d\vec{r} g(\vec{r})e^{i\vec{k}\cdot \vec{r}}.$$ My question is that why the intensity of scattering is related to the Fourier transform like this. Also, this resembles the so-called atomic form factor inside the structure factor for a crystal. For your reference, the structure factor is defined to be $$S(\vec{k})=\sum_{j=1}^n f_j(\vec{k})e^{i\vec{k}\cdot \vec{d}_j}$$ where the summation is over all the atoms, whose position are given by $\vec{d}_j$, in a particular basis (e.g. $n=2$ for a honeycomb lattice). The $f_j(\vec{k})$ in the above expression is the atomic factor, which again is directly proportional to the Fourier transform of the charge density due to the atom at $\vec{d}_j$, i.e. $$f_j(\vec{k})\propto \int d\vec{r} \rho (\vec{r})e^{i\vec{k}\cdot \vec{r}}$$ Therefore, both of the two cases are related to scattering amplitude, but the former is regarding the Fourier transform of the correlation function, which can be quite different for different systems, and the latter is regarding the transform of the charge density.
So again why is the Fourier transforms related to the scattering intensity and are the two cases interrelated somehow?