# latitude derivations

1. latitude from polygon

   symbol | description | unit | variable name
   --- | --- | --- | ---
   \(\lambda\) | longitude | \(degE\) | longitude {:}
   \(\lambda^{B}(i)\) | longitude | \(degE\) | longitude_bounds {:,N}
   \(\phi\) | latitude | \(degN\) | latitude {:}
   \(\phi^{B}(i)\) | latitude | \(degN\) | latitude_bounds {:,N}

   The centroid is determined from the normal vector of the polygon area, which is the sum of the area weighted moments of consecutive vertices \(\mathbf{p}(i)\), \(\mathbf{p}(i+1)\) for all polygon edges (with \(\mathbf{p}(N+1):=\mathbf{p}(1)\)).

   Convert all polygon corner coordinates defined by \(\phi^{B}(i)\) and \(\lambda^{B}(i)\) into unit sphere points \(\mathbf{p}(i) = [x_{i}, y_{i}, z_{i}]\)

   \[\begin{split}\begin{eqnarray} w_{i} & = & \frac{1}{2} \begin{cases} \mathbf{p}(i) \cdot \mathbf{p}(i+1) \lt 0, & \pi - 2 asin(\frac{\Vert\mathbf{p}(i) + \mathbf{p}(i+1)\Vert}{2}) \\ \mathbf{p}(i) \cdot \mathbf{p}(i+1) \ge 0, & 2 asin(\frac{\Vert\mathbf{p}(i) - \mathbf{p}(i+1)\Vert}{2}) \end{cases} \\ \mathbf{p}_{center} & = & \sum_{i}{w_{i} \frac{\mathbf{p}(i) \times \mathbf{p}(i+1)}{\Vert\mathbf{p}(i) \times \mathbf{p}(i+1)\Vert}} \\ \end{eqnarray}\end{split}\]

   The vector \(\mathbf{p}_{center}\) is converted back to \(\phi\) and \(\lambda\)

2. latitude from range

   symbol | description | unit | variable name
   --- | --- | --- | ---
   \(\phi\) | latitude | \(degN\) | latitude {:}
   \(\phi^{B}(l)\) | latitude boundaries (\(l \in \{1,2\}\)) | \(degN\) | latitude_bounds {:,2}

   The pattern : for the dimensions can represent {latitude}, or {time,latitude}.

   \[\phi = \frac{\phi^{B}(2) + \phi^{B}(1)}{2}\]

3. latitude from vertical profile latitudes

   symbol | description | unit | variable name
   --- | --- | --- | ---
   \(\phi\) | single latitude for the full profile | \(degN\) | latitude {:}
   \(\phi(i)\) | latitude for each profile point | \(degN\) | latitude {:,vertical}
   \(N\) | number of profile points |  |

   The pattern : for the dimensions can represent {time}, or no dimensions at all.

   \[\begin{split}\begin{eqnarray} N & = & max(i, \phi(i) \neq NaN) \\ \phi & = & \phi(N/2) \end{eqnarray}\end{split}\]

4. latitude from sensor latitude

   symbol | description | unit | variable name
   --- | --- | --- | ---
   \(\phi\) | latitude | \(degN\) | latitude {:}
   \(\phi_{instr}\) | latitude of the sensor | \(degN\) | sensor_latitude {:}

   The pattern : for the dimensions can represent {time}, or no dimensions at all.

   \[\phi = \phi_{instr}\]