# Extra:Intersecting planes

A common problem in scattering is to consider the intersection of various planes (representing the Ewald sphere, reciprocal space, etc.).

## Angle between two planes

The general case for the angle between two planes is well known. Consider a particular case where we want to know how the angle between two planes depends on the direction/orientation of a third plane/vector that intersects the first two. I.e. what is the minimal angle between two planes along a 'certain direction' (what is the angle between two vectors that both lie on the third plane, and which lie on planes 1 and 2, respectively).

One of the planes represents reciprocal-space scattering (e.g. mostly localized to a plane); the other represents the detector. We are interested in the angle between them so that we can calculate the distance between them, so that we can compute 'how much' scattering is seen on the detector. To make this concrete, plane 1 lies in the $\scriptstyle xy$ plane, and thus has normal vector:

$\mathbf{n}_1 = \begin{bmatrix} 0 & 0 & 1 \end{bmatrix}$

The first plane intersects the origin. The second plane also intersects the origin, but is tilted about the $\scriptstyle x$-axis by $\scriptstyle \alpha$, such that its normal is:

$\mathbf{n}_2 = \begin{bmatrix} 0 & - \sin \alpha \ & \cos \alpha \end{bmatrix}$

We are interested in quantities that are a particular distance ($\scriptstyle q$) from the origin. Imagine a vector of length $\scriptstyle q$ lying in plane 1, rotated about the $\scriptstyle z$ axis by $\scriptstyle \phi$ (i.e. the angular distance from the $\scriptstyle y$-axis is $\scriptstyle \phi$):

$\mathbf{v}_1 = \begin{bmatrix} q \sin \phi & q \cos \phi \ & 0 \end{bmatrix}$

The second vector ($\scriptstyle \mathbf{v}_2$) is lying in plane 2. We call $\scriptstyle \alpha_r$ the angle between $\scriptstyle \mathbf{v}_1$ and $\scriptstyle \mathbf{v}_2$. The specified geometry uniquely defines $\scriptstyle \alpha_r$ in terms of the angle between the planes ($\scriptstyle \alpha$) and the amount of rotation of the vectors ($\scriptstyle \phi$) within their respective planes. In particular, $\scriptstyle \mathbf{v}_2$ can be thought of as $\scriptstyle \mathbf{v}_{2b}$ rotated about $\scriptstyle \mathbf{n}_2$ by $\scriptstyle \phi$, where $\scriptstyle \mathbf{v}_2b$ is the vector in plane 2 without any $\scriptstyle \phi$ rotation (i.e. lying in the $\scriptstyle yz$ plane):

$\mathbf{v}_{2b} = \begin{bmatrix} 0 & q \cos \alpha \ & q \sin \alpha \end{bmatrix}$

In general, rotation of a vector $\scriptstyle \mathbf{v}_{\mathrm{start}} = \begin{bmatrix} x & y & z \end{bmatrix}$ about an arbitrary unit-vector $\scriptstyle \mathbf{n} = \begin{bmatrix} u & v & w \end{bmatrix}$ gives (1, 2):

$\mathbf{v}_{\mathrm{end}} = \begin{bmatrix} u(ux +vy+wz)(1-\cos \theta) + x \cos \theta + (-wy+vz)\sin \theta \\ v(ux+vy+wz)(1 - \cos \theta) + y \cos \theta + (wx-uz) \sin \theta\\ w(ux+vy+wz)(1-\cos \theta) + z \cos \theta + (-vx+uy) \sin \theta \end{bmatrix}$

In this particular case, we thus expect:

\begin{alignat}{2} \mathbf{v}_{2} & = \begin{bmatrix} (-wy+vz)\sin \phi \\ v(vy+wz)(1 - \cos \phi) + y \cos \phi \\ w(vy+wz)(1-\cos \phi) + z \cos \phi\end{bmatrix} \\ & = \begin{bmatrix} (- \cos\alpha q \cos\alpha + -\sin\alpha q \sin\alpha)\sin \phi \\ -\sin\alpha(-\sin\alpha q \cos\alpha+\cos\alpha q \sin\alpha)(1 - \cos \phi) + q \cos\alpha \cos \phi \\ \cos\alpha(-\sin\alpha q \cos\alpha+ \cos\alpha q \sin\alpha)(1-\cos \phi) + q \sin\alpha \cos \phi\end{bmatrix} \\ & = q \begin{bmatrix} -(\cos^2 \alpha +\sin ^2 \alpha)\sin \phi \\ \sin^2 \alpha(\cos\alpha-\cos\alpha )(1 - \cos \phi) + \cos\alpha \cos \phi \\ \cos^2 \alpha(-\sin\alpha + \sin\alpha)(1-\cos \phi) + \sin\alpha \cos \phi\end{bmatrix} \\ & = q \begin{bmatrix} -\sin \phi \\ \cos\alpha \cos \phi \\ \sin\alpha \cos \phi\end{bmatrix} \end{alignat}

Note that we replace $\scriptstyle \phi$ by $\scriptstyle -\phi$ to force the same orientation convention in the definition of rotating $\scriptstyle \mathbf{v}_1$ and $\scriptstyle \mathbf{v}_2$:

\begin{alignat}{2} \mathbf{v}_{2} & = q \begin{bmatrix} \sin \phi \\ \cos\alpha \cos \phi \\ \sin\alpha \cos \phi\end{bmatrix} \end{alignat}

The angle between $\scriptstyle \mathbf{v}_1$ and $\scriptstyle \mathbf{v}_2$ is $\scriptstyle \alpha_r$:

\begin{alignat}{2} \cos \alpha_r & = \frac{\mathbf{v}_1 \cdot \mathbf{v}_2}{|\mathbf{v}_1| |\mathbf{v}_2|} \\ & = \frac{(q^2 \sin \phi \sin \phi)+(q^2\cos \phi \cos \alpha \cos\phi)+(0)}{(q) (q)} \\ & = \sin^2 \phi + \cos^2 \phi \cos \alpha \\ \alpha_r & = \cos^{-1}\left[ \cos^2 \phi \cos \alpha + \sin^2 \phi \right ] \end{alignat}

## Distance between two planes

The distance between $\scriptstyle \mathbf{v}_1$ and $\scriptstyle \mathbf{v}_2$ is $\scriptstyle d$:

\begin{alignat}{2} \sin \left( \frac{\alpha_r}{2} \right ) & = \frac{d/2}{q} \\ d & = 2 q \sin \left( \frac{\alpha_r}{2} \right ) \\ & = 2 q \sin \left( \frac{1}{2} \cos^{-1} \left[ \cos^2 \phi \cos \alpha + \sin^2 \phi \right ] \right ) \end{alignat}

Alternatively:

\begin{alignat}{2} d^2 & = 2 q^2 - 2 q^2 \cos \alpha_r \\ d & = q \sqrt{ 2 \left ( 1 - \cos \alpha_r \right ) } \\ d & = q \sqrt{ 2 \left ( 1 - \cos \left( \cos^{-1} \left[ \cos^2 \phi \cos \alpha + \sin^2 \phi \right ] \right ) \right ) } \\ d & = q \sqrt{ 2 \left ( 1 - \cos^2 \phi \cos \alpha + \sin^2 \phi \right ) } \end{alignat}

If the two vectors do not have equal length:

\begin{alignat}{2} d^2 & = q_1^2 + q_2^2 - 2 q_1q_2 \cos \alpha_r \\ d & = \sqrt{ q_1^2 + q_2^2 - 2 q_1q_2 \left( \cos^2 \phi \cos \alpha + \sin^2 \phi \right) }\\ \end{alignat}

## Generalized intersection

Imagine reciprocal-space scattering that is a ring; more specifically a pseudo-toroid with Gaussian-like decay. The intensity overall is:

$I = \exp \left [ -(q_{rr}-q_0)^2/(2 \sigma_q^2) \right ] \exp \left [ -q_{rz}^2/(2 \sigma_q^2) \right ]$

Where we use the subscript r to denote the reciprocal-space coordinate system, and $\scriptstyle q_{rr} = \sqrt{q_{rx}^2+q_{ry}^2}$. The plane of the detector (i.e. the Ewald plane) is denoted by d:

$\mathbf{v}_{d} = \begin{bmatrix} q_{dx} & q_{dy} & 0 \end{bmatrix}$

We set the symmetry axis in realspace (detector coordinate system) to be the $\scriptstyle x$-axis. The reciprocal-space is tilted by $\scriptstyle \chi_0$ (about the $\scriptstyle y$-axis), before the 'powder' rotation about the $\scriptstyle x$-axis (where $\scriptstyle \alpha$ goes from $\scriptstyle -\pi$ to $\scriptstyle +\pi$). Consider an initial vector:

$\mathbf{v}_{d0} = \begin{bmatrix} q \sin \phi & q \cos \phi & 0 \end{bmatrix}$

The 1st rotation (about $\scriptstyle y$-axis by $\scriptstyle \chi_0$) involves:

\begin{alignat}{2} \mathbf{v}_{d1} & = R_y(\chi_0) \mathbf{v}_{d0} \\ & = \begin{bmatrix} \cos \chi_0 & 0 & \sin \chi_0 \\ 0 & 1 & 0 \\ -\sin \chi_0 & 0 & \cos \chi_0 \\ \end{bmatrix} \begin{bmatrix} q \sin \phi \\ q \cos \phi \\ 0 \\ \end{bmatrix} \\ & = \begin{bmatrix} q \sin \phi \cos \chi_0 \\ q \cos \phi \\ - q \sin \phi \sin \chi_0 \\ \end{bmatrix} \end{alignat}

The 2nd rotation (about the $\scriptstyle q_{dx}$-axis by $\scriptstyle \alpha$) occurs with respect to the vector:

\begin{alignat}{2} \mathbf{u}_{d1} & = R_y(\chi_0) \mathbf{u}_{d0} \\ & = \begin{bmatrix} \cos \chi_0 & 0 & \sin \chi_0 \\ 0 & 1 & 0 \\ -\sin \chi_0 & 0 & \cos \chi_0 \\ \end{bmatrix} \begin{bmatrix} 1 \\ 0 \\ 0 \\ \end{bmatrix} \\ & = \begin{bmatrix} \cos \chi_0 \\ 0 \\ - \sin \chi_0 \\ \end{bmatrix} \end{alignat}

The second rotation can again be thought of in general terms as $\scriptstyle \mathbf{v}_{\mathrm{start}} = \begin{bmatrix} x & y & z \end{bmatrix}$ rotated by $\scriptstyle \theta$ about an unit-vector $\scriptstyle \mathbf{u} = \begin{bmatrix} u & v & w \end{bmatrix}$.

$\mathbf{v}_{\mathrm{end}} = \begin{bmatrix} u(ux +vy+wz)(1-\cos \theta) + x \cos \theta + (-wy+vz)\sin \theta \\ v(ux+vy+wz)(1 - \cos \theta) + y \cos \theta + (wx-uz) \sin \theta\\ w(ux+vy+wz)(1-\cos \theta) + z \cos \theta + (-vx+uy) \sin \theta \end{bmatrix}$

In this case:

\begin{alignat}{2} \mathbf{v}_{\mathrm{start}} & = \begin{bmatrix} x \\ y \\ z \end{bmatrix} = \mathbf{v}_{d1} = \begin{bmatrix} q \sin \phi \cos \chi_0 \\ q \cos \phi \\ -q \sin \phi \sin \chi_0 \end{bmatrix} \\ \mathbf{u} & = \begin{bmatrix} u \\ v \\ w \end{bmatrix} = \mathbf{u}_{d1} = \begin{bmatrix} \cos \chi_0 \\ 0 \\ -\sin \chi_0 \end{bmatrix} \end{alignat}

This reduces the problem to:

$\mathbf{v}_{\mathrm{end}} = \begin{bmatrix} u(ux +wz)(1-\cos \alpha) + x \cos \alpha + -wy \sin \alpha \\ y \cos \alpha + (wx-uz) \sin \alpha\\ w(ux+wz)(1-\cos \alpha) + z \cos \alpha + uy \sin \alpha \end{bmatrix}$

More specifically:

\begin{alignat}{2} \mathbf{v}_{d2} & = \begin{bmatrix} \cos \chi_0 (\cos \chi_0 q \sin \phi \cos \chi_0 +\sin \chi_0 q \sin \phi \sin \chi_0)(1-\cos \alpha) + q \sin \phi \cos \chi_0 \cos \alpha +\sin \chi_0 q \cos \phi \sin \alpha \\ q \cos \phi \cos \alpha + (-\sin \chi_0 q \sin \phi \cos \chi_0 + \cos \chi_0 q \sin \phi \sin \chi_0 ) \sin \alpha\\ -\sin \chi_0 ( \cos \chi_0 q \sin \phi \cos \chi_0 +\sin \chi_0 q \sin \phi \sin \chi_0 )(1-\cos \alpha) -q \sin \phi \sin \chi_0 \cos \alpha + \cos \chi_0 q \cos \phi \sin \alpha \end{bmatrix} \\ & = q \begin{bmatrix} \cos \chi_0 \sin \phi(\cos^2 \chi_0 +\sin^2 \chi_0 )(1-\cos \alpha) + \sin \phi \cos \chi_0 \cos \alpha +\sin \chi_0 \cos \phi \sin \alpha \\ \cos \phi \cos \alpha + \sin \phi (-\sin \chi_0 \cos \chi_0 + \cos \chi_0 \sin \chi_0 ) \sin \alpha\\ -\sin \chi_0 \sin \phi ( \cos^2 \chi_0 +\sin^2 \chi_0 )(1-\cos \alpha) - \sin \phi \sin \chi_0 \cos \alpha + \cos \chi_0 \cos \phi \sin \alpha \end{bmatrix} \\ & = q \begin{bmatrix} \cos \chi_0 \sin \phi(1-\cos \alpha) + \sin \phi \cos \chi_0 \cos \alpha +\sin \chi_0 \cos \phi \sin \alpha \\ \cos \phi \cos \alpha\\ -\sin \chi_0 \sin \phi (1-\cos \alpha) - \sin \phi \sin \chi_0 \cos \alpha + \cos \chi_0 \cos \phi \sin \alpha \end{bmatrix} \\ \end{alignat}

This vector describes the possible positions of the intersecting detector-plane, in the sample's reciprocal-space.