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:

Check
As a check of these results, consider:

Where we used:
![{\displaystyle {\begin{alignedat}{2}\sin(\arctan[u])&={\frac {u}{\sqrt {1+u^{2}}}}\\\sin \theta _{f}&=\sin(\arctan[x/d])\\&={\frac {x/d}{\sqrt {1+(x/d)^{2}}}}\\&={\frac {x}{\sqrt {d^{2}+x^{2}}}}\end{alignedat}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/fc9628f0d308053600f4e02d8f80c69fc9f356d0)
And, we further note that:
![{\displaystyle {\begin{alignedat}{2}\cos(\arctan[u])&={\frac {1}{\sqrt {1+u^{2}}}}\\\cos \theta _{f}&={\frac {1}{\sqrt {1+(x/d)^{2}}}}\\&={\frac {d^{2}}{\sqrt {d^{2}+x^{2}}}}\end{alignedat}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/584da470743b7feac2b55988526dabce5b4313c4)
Continuing:
![{\displaystyle {\begin{alignedat}{2}{\frac {q^{2}}{k^{2}}}&=?\\&=?\\&=?\\&=?\\&=?\\&={\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/96f779b6f625f912acd1f98a914ab464d33cecd6)