\section{Starting to Deal With the Poles}
It is time to deal with the pole situation. The north and south poles that is, not the lovely people over in Poland. We run into problems because the latitude longitude grid cells become to small 
near the poles. Therefore, the magnitudes no longer fit into one cell and overflow into other cells which makes everything kind of funky. So we need to fix that, and we do that by a planar 
approximation. 

\subsection{The Theory Behind the Planar Approximation}
As said earlier, the grid cells on the latitude longitude grid get closer together the closer you get to the poles which poses problems. To fix this, we will be using a planar approximation of 
the poles. What this means is that we will map the 3D grid near the poles onto a 2D plane parallel to the poles, as if we put a giant flat plane in the exact center of the poles and draw lines
from the grid directly upwards to the plane. For a visual representation, please consult the stream with timestamp 1:38:25 \cite{polarPlane}, which includes some explanation. In the streamm we
use $r$ to indicate the radius of the planet (which we assume is a sphere), $\theta$ for the longitude and $\lambda$ for the latitude. So we have spherical coordinates, which we need to transform
into $x$ and $y$ coordinates on the plane. We also need the distance between the center point (the point where the plane touches the planet which is the center of the pole) and the projected 
point on the plane from the grid (the location on the plane where a line from the gird upwards to the plane hits it). This distance is denoted by $a$ (Simon chose this one, not me). We then get 
the following equations as shown in \autoref{eq:polar distance}, \autoref{eq:polar x} and \autoref{polar y}. 

\begin{subequations}
    \begin{equation}
        a = r \cos(\theta)
        \label{eq:polar distance}
    \end{equation}
    \begin{equation}
        x = a \sin(\lambda)
        \label{eq:polar x}
    \end{equation}
    \begin{equation}
        y = a \cos(\lambda)
        \label{eq:polar y}
    \end{equation}
\end{subequations}

But what if we know $x$ and $y$ and want to know $\theta$ and $\lambda$? Pythagoras' Theorem then comes into play \cite{pythagoras}. We know that (due to Pythagoras) \autoref{eq:pythagoras} must 
always be true. Then if we substitue $a$ by $\sqrt{x^2 + y^2}$ in \autoref{eq:polar distance} we get \autoref{eq:polar theta1}. Then we transform that equation such that we only have $\theta$ on 
one side and the rest on the other side (since we want to know $\theta$) and we get \autoref{eq:polar theta3}.
\begin{equation}
    x^2 + y^2 = a^2
    \label{eq:pythagoras}
\end{equation}

\begin{subequations}
    \begin{equation}
        \sqrt{x^2 + y^2} = r\cos(\theta)
        \label{eq:polar theta1}
    \end{equation}
    \begin{equation}
        \frac{\sqrt{x^2 + y^2}}{r} = \cos(\theta)
        \label{eq:polar theta2}
    \end{equation}
    \begin{equation}
        \cos^{-1}(\frac{\sqrt{x^2 + y^2}}{r}) = \theta
        \label{eq:polar theta3}
    \end{equation}
\end{subequations}

For $\lambda$ we need another trigonometric function which is the tangent ($\tan$). The tangent is defined in \autoref{eq:tan}. If we then take a look at \autoref{eq:polar x} and 
\autoref{eq:polar y}, we see that $\lambda$ is present in both equations. So we need to use both to get $\lambda$ \footnote{Yes you could only use one but since we both know $x$ and $y$ it is a
bit easier to use both than to only use one as you need to know $\theta$ at that point as well which may or may not be the case.}. So let's combine \autoref{eq:polar x} and \autoref{eq:polar y}
in \autoref{eq:polar lambda1}, transform it such that we end up with only $\lambda$ on one side and the rest on the other side and we end up with \autoref{eq:polar lambda3}.

\begin{equation}
    \tan(\alpha) = \frac{\sin(\alpha)}{\cos(\alpha)}
    \label{eq:tan}
\end{equation}

\begin{subequations}
    \begin{equation}
        \frac{x}{y} = \frac{a\sin(\lambda)}{a\cos(\lambda)} = \frac{\sin(\lambda)}{\cos(\lambda)}
        \label{eq:polar lambda1}
    \end{equation}
    \begin{equation}
        \frac{x}{y} = \tan(\lambda)
        \label{eq:polar lambda2}
    \end{equation}
    \begin{equation}
        \lambda = \tan^{-1}(\frac{x}{y})
        \label{eq:polar lambda3}
    \end{equation}
\end{subequations}

With this math we can fix a lot of stuff in the model. With this we can resample (mapping from sphere to plane) the pressure, density, temperarature and advection to the plane and ensure that 
there are no more overflows and funky business. The implementation (code) for this will be done in a follow up stream, so stay tuned!