The q-vector in fact has three components:

Consider that the x-ray beam points along +y, so that on the detector, the horizontal is x, and the vertical is z. We assume that the x-ray beam hits the flat 2D area detector at 90° at detector (pixel) position
. The scattering angles are then:
![{\displaystyle {\begin{alignedat}{2}\theta _{f}&=\arctan \left[{\frac {x}{d}}\right]\\\alpha _{f}^{\prime }&=\arctan \left[{\frac {z}{d}}\right]\\\alpha _{f}&=\arctan \left[{\frac {z}{d/\cos \theta _{f}}}\right]\end{alignedat}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/facc9ad57cd58f15e7403d40dc08f08815d3662b)
where
is the sample-detector distance,
is the out-of-plane component (angle w.r.t. to y-axis, rotation about x-axis), and
is the in-plane component (rotation about z-axis). The alternate angle,
, is the elevation angle in the plane defined by
. Also note that the full scattering angle is:
![{\displaystyle {\begin{alignedat}{2}2\theta _{s}=\Theta &=\arctan \left[{\frac {\sqrt {x^{2}+z^{2}}}{d}}\right]\\&=\arctan \left[{\frac {\sqrt {(d\tan \theta _{f})^{2}+(d\tan \alpha _{f}^{\prime })^{2}}}{d}}\right]\\&=\arctan \left[{\sqrt {\tan ^{2}\theta _{f}+\tan ^{2}\alpha _{f}^{\prime }}}\right]\\&=\arctan \left[{\sqrt {\tan ^{2}\theta _{f}+{\frac {\tan ^{2}\alpha _{f}}{\cos ^{2}\theta _{f}}}}}\right]\\\end{alignedat}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/ce190aa4f7dd836349234c33033cb245c49d4f20)
The momentum transfer components are:

later
As a check:
![{\displaystyle {\begin{alignedat}{2}q&={\sqrt {q_{x}^{2}+q_{y}^{2}+q_{z}^{2}}}\\&={\frac {2\pi }{\lambda }}{\sqrt {\sin ^{2}\theta _{f}\cos ^{2}\alpha _{f}+\left(\cos \theta _{f}\cos \alpha _{f}-1\right)^{2}+\sin ^{2}\alpha _{f}}}\\{\frac {q}{k}}&={\sqrt {(\sin \theta _{f})^{2}(\cos \alpha _{f})^{2}+\left(\cos \theta _{f}\cos \alpha _{f}-1\right)^{2}+(\sin \alpha _{f})^{2}}}\\{\frac {q^{2}}{k^{2}}}&=\left({\frac {x/d}{\sqrt {1+(x/d)^{2}}}}\right)^{2}\left(\cos \alpha _{f}\right)^{2}+\left(\cos \theta _{f}\cos \alpha _{f}-1\right)^{2}+\left({\frac {z\cos \theta _{f}/d}{\sqrt {1+(z\cos \theta _{f}/d)^{2}}}}\right)^{2}\\&=\left({\frac {x}{\sqrt {d^{2}+x^{2}}}}\right)^{2}\left(\cos \alpha _{f}\right)^{2}+\left(\cos \theta _{f}\cos \alpha _{f}-1\right)^{2}+\left({\frac {z\cos \theta _{f}}{\sqrt {d^{2}+z^{2}\cos ^{2}\theta _{f}}}}\right)^{2}\\&={\frac {x^{2}}{d^{2}+x^{2}}}\left(\cos \alpha _{f}\right)^{2}+\left(\cos \theta _{f}\cos \alpha _{f}-1\right)^{2}+{\frac {z^{2}\cos ^{2}\theta _{f}}{d^{2}+z^{2}\cos ^{2}\theta _{f}}}\\&={\frac {x^{2}}{d^{2}+x^{2}}}{\frac {d^{4}}{d^{2}+z^{2}\cos ^{2}\theta _{f}}}+\left(\cos \theta _{f}{\frac {d^{2}}{\sqrt {d^{2}+z^{2}\cos ^{2}\theta _{f}}}}-1\right)^{2}+{\frac {z^{2}\cos ^{2}\theta _{f}}{d^{2}+z^{2}\cos ^{2}\theta _{f}}}\\&=?\\&=?\\&=?\\&=?\\&=?\\&={\frac {x^{2}+z^{2}}{d^{2}+x^{2}+z^{2}}}\\{\frac {q}{k}}&={\sqrt {\frac {x^{2}+z^{2}}{d^{2}+x^{2}+z^{2}}}}\\&={\frac {\sqrt {x^{2}+z^{2}}}{\sqrt {d^{2}+x^{2}+z^{2}}}}\\&={\frac {\left[{\sqrt {x^{2}+z^{2}}}/d\right]}{\sqrt {1+\left[{\sqrt {x^{2}+z^{2}}}/d\right]^{2}}}}\\&=\sin \left(\arctan \left[{\frac {\sqrt {x^{2}+z^{2}}}{d}}\right]\right)\\q&={\frac {2\pi }{\lambda }}\sin \left(2\theta _{s}\right)\end{alignedat}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/785c485d65c4c1d0db7f0a9bf38e80a83c264936)