1%\documentclass{book}
2%\begin{document}
3\chapter{Converting Coordinates \& Time}
4\section{Transformations}
5
6Let $\mathbf{i}_{x}$, $\mathbf{i}_{y}$, $\mathbf{i}_{z}$ and $\mathbf{i}_{\varepsilon}$, $\mathbf{i}_{\eta}$, $\mathbf{i}_{\zeta}$ be two sets of orthogonal unit vectors
7
8\[\mathbf{i}_{\xi}=l_{1}\mathbf{i}_{x}+m_{1}\mathbf{i}_{y}+n_{1}\mathbf{i}_{z}\]
9\[\mathbf{i}_{\eta}=l_{2}\mathbf{i}_{x}+m_{2}\mathbf{i}_{y}+n_{2}\mathbf{i}_{z}\]
10\[\mathbf{i}_{\zeta}=l_{3}\mathbf{i}_{x}+m_{3}\mathbf{i}_{y}+n_{3}\mathbf{i}_{z}\]
11
12\[ \left[ \begin{array}{c} x \\ y \\ z  \end{array} \right] = \mathbf{R}\left[ \begin{array}{c} \varepsilon \\ \eta \\ \zeta  \end{array} \right] \mbox{or}
13\left[ \begin{array}{c} \varepsilon \\ \eta \\ \zeta  \end{array} \right] = \mathbf{R^{T}}\left[ \begin{array}{c} x \\ y \\ z  \end{array} \right] \]
14
15\[\mathbf{R}=\left[ \begin{array}{ccc}
16\mathbf{i}_{x}\mathbf{\cdot}\mathbf{i}_{\varepsilon} & \mathbf{i}_{x}\mathbf{\cdot}\mathbf{i}_{\eta} & \mathbf{i}_{x}\mathbf{\cdot}\mathbf{i}_{\zeta} \\
17\mathbf{i}_{y}\mathbf{\cdot}\mathbf{i}_{\varepsilon} & \mathbf{i}_{y}\mathbf{\cdot}\mathbf{i}_{\eta} & \mathbf{i}_{y}\mathbf{\cdot}\mathbf{i}_{\zeta} \\
18\mathbf{i}_{z}\mathbf{\cdot}\mathbf{i}_{\varepsilon} & \mathbf{i}_{z}\mathbf{\cdot}\mathbf{i}_{\eta} & \mathbf{i}_{z}\mathbf{\cdot}\mathbf{i}_{\zeta}
19\end{array} \right] = \left[ \begin{array}{ccc}
20l_{1} & l_{2} & l_{3} \\
21m_{1} & m_{2} & m_{3} \\
22n_{1} & n_{2} & n_{3}
23\end{array} \right] \]
24
25\[ \mathbf{R^{T}}=\mathbf{R^{-1}} \]
26
27Equations found  here~\cite[pp. 81-82]{battin:imma}
28
29\section{Time Systems}
30\subsection{Solar \& Sidereal Time}
31Since the  beginning time has been kept by counting the days. An apparent solar day is the minimum time elapsed between the sun crossing a specified meridian and then recrossing the same meridian. This form of time keeping is problematic because no two apparent solar days are of the same duration due to Earth's rotation around the sun as well as around its axis (the Earth does a little more than one rotation per apparent solar day). Also, Earth's rotational speed is not constant and its axis of rotation is tilted $23.5^{\circ}$ to the orbital plane. These imperfections call for correction, and thus mean solar time was created. A day in mean solar time is defined as one revolution of a hypothetical sun that orbits at the equator, and is more commonly known as Greenwich Mean Time. Another solution is to base our day on the crossing of a star much farther away thus minimizing the effect of the Earth's orbital movement, this method of time keeping is known as sidereal time. A sidereal day is about 4 minutes shorter than a solar day, and is used heavily by astronomers. Sidereal time is not truly stable either so mean sidereal day was introduced, and is known as Greenwich Apparent Sidereal Time. Universal Time (UT) refers to any time scale based on the Earth's rotation. UT0 refers to the mean solar time at the prime meridian as obtained from astronomical observation, and UT1 is UT0 corrected for polar motion. Briefly ephemeris time was introduced to standardize the second, which was defined as 1/31556925.9747 of the year 1900. This was soon replaced by atomic time~\cite[pp. 84-86]{me:gsmp}.
32\subsection{Atomic Time}
33The second is now defined by an atomic standard that is based on the resonance frequency of the cesium atom. To be precise, the second is defined as ``9,192,631,770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the cesium-133 atom,'' whose duration happens to exactly match the ephemeris second discussed in the previous section. The problem with detaching our time keeping method from the Earth is that as the Earth slows its rotation noon will move closer to midnight (over the duration of thousands of years, of course). Coordinated Universal Time (UTC) was introduced to prevent this. UTC is a compromise between the precision of atomic time and the groundedness of Earth based time keeping, it uses the atomic second but introduces leap seconds (positive or negative) when necessary to keep UTC within .9 seconds of UT1~\cite[pp. 86-87]{me:gsmp}.
34\subsection{Time Formats}
35We are used to dealing with months, days, years, hours, minutes, and seconds, but such a time format makes for difficult epoch calculations over long periods. To solve this problem Julian Date (JD) was introduced. JD consists of a day count (days since noon UT on January $1^{\mbox{st}}$ 4713 B.C.) and a fraction of the current day. This makes for easy time differencing, but the length of the date can become cumbersome and the fact that a new day starts at noon confusing. To make things even easier Modified Julian Date (MJD) was created whose origin is midnight November $17^{\mbox{th}}$, 1858.
36\[ \mbox{MJD}=\mbox{JD}-2400000.5\]
37
38In order to make Julian Date useful we need an easy way to go between calendar dates and JD. \application{timeconvert}\index{timeconvert!theory} does this and more with ease. The equations to convert from calendar date to JD are
39\[ \mbox{JD}=\mbox{INT}[365.25y]+\mbox{INT}[30.6001(m+1)]+D+\mbox{UT}/24+1720981.5\]
40\[ \begin{array}{lll}
41y=Y-1 & \mbox{and}~m=M+12 & \mbox{if}~M \leq2 \\
42y=Y & \mbox{and}~m=M & \mbox{if}~M > 2
43\end{array} \]
44where $M$ is the month, $D$ is the day, $Y$ is the year, and INT[$x$] returns just the integer part of the number. To go from JD to calendar date
45\[ a=\mbox{INT[JD}+0.5] \]
46\[ b=a+1537 \]
47\[ c=\mbox{INT}[(b-122.1)/365.25] \]
48\[ d=\mbox{INT}[365.25c] \]
49\[ e=\mbox{INT}[(b-d)/30.6001] \]
50\[ D=b-d-\mbox{INT}[30.6001e]+\mbox{FRAC[JD}+0.5] \]
51\[ M=e-1-12\mbox{INT}[e/14] \]
52\[ Y=c-4715-\mbox{INT}[(7+M)/10] \]
53where FRAC[$x$] returns just the fractional part of a real number. MJD Conversion found here~\cite[p. 88]{me:gsmp}. All other date conversions were found here~\cite[pp. 36-37]{hlc:gtp}
54\subsection{GPS Time}
55GPS Time (GPST) is a continuously running composite time kept by cesium and rubidium frequency standards aboard the satellites and at monitor stations. While there are no leap seconds in GPST as there are in UTC, it is steered to stay within 1 $\mu$s of UTC, that is the difference between GPST and UTC is an integer number of seconds plus a fraction of a $\mu$s. GPST is formatted in terms of GPS weeks and the number of seconds into the current week. Finding these values is done easily if the Julian Date is known.
56\[ \mbox{GPS WEEK}=\mbox{INT[(JD}-2444244.5)/7] \]
57\[ \mbox{SOW}=\mbox{FRAC[(JD}-2444244.5)/7]\times 604800 \]
58where INT[$x$] returns the integer part of a real number, FRAC[$x$] returns the fractional part, and SOW stands for Second of Week.
59
60Other useful quantities such as Day of Week and  Second of Day can be found using \application{timeconvert}\index{timeconvert!theory} or the following equations.
61\[\mbox{DOW}=\mbox{modulo\{INT[JD}+0.5],7\}\]
62\[\mbox{SOD}=\mbox{modulo\{FRAC[JD}+0.5],7\}\times 86400\]
63where DOW=0 corresponds to Monday, DOW=1 corresponds to Tuesday, and so on.
64
65JD and GPS Week equations were found here~\cite[pp. 36-37]{hlc:gtp}, SOD derived from DOW equation.
66\subsection{Z-Count}
67Satellites keep internal time with Z-count, whose epoch period is 1.5 seconds (a convenient unit for communications timing). The full Z-count is 29 bits, the 10 bit GPS week folloed by a 19 bit Time of Week (TOW) expressed in Z-counts (or 1.5 second units). The truncated Z-count has a 17 bit TOW that is expressed in units of 6 seconds, or the length of one subframe's transmission time. Simply multiply the truncated TOW by 4 to get the full TOW~\cite[pp. 86-88]{tsui:fgpsr}.
68\[ \mbox{TOW}=\mbox{FRAC[(JD}-2444244.5)/7]\times 403200 \]
69\[ \mbox{Truncated TOW}=\mbox{FRAC[(JD}-2444244.5)/7]\times 100800 \]
70Equations derived from SOW equation above
71\section{Earth Fixed Coordinates}
72\subsection{ECI to ECF}
73\[\left[\begin{array}{c} x \\ y \\ z \end{array}\right]_{ECF}=T_{XYZ}^{xyz}\left[\begin{array}{c} X \\ Y \\ Z \\ \end{array}\right]_{ECI}\]
74\[T_{XYZ}^{xyz}=WSNP\]
75
76P - applies precession, from epoch 2000.0 to the current time;
77N - applies nutation, from epoch 2000.0 to the current time;
78S - applies rotation to account for true sidereal time;
79W - applies polar motion;
80
81Equations found on page 85 of Fundamentals of Orbit Determination paper book.
82
83\subsection{WGS-84}
84The World Geodetic System 1984 (WGS-84) is a fixed physical model of Earth produced by the Department of Defense to which many different reference frames can be attached. WGS-84 consists of two parts, a model of Earth's gravitational field, and an ellipsoid describing the Earth's general shape. When dealing with locations on the Earth's surface the ellipsoid provides the foundation for the geodetic coordinate system used by GPS. The ellipsoid's cross-sections parallel to the equatorial plane are circular while those orthogonal are elliptical. The ellipses are parameterized by an eccentricity $e$, a flattening $f$, and sometimes a second eccentricity $e'$
85\[e=\sqrt{1-\frac{b^{2}}{a^{2}}}\]
86\[f=1-\frac{b}{a}\]
87\[e'=\sqrt{\frac{a^{2}}{b^{2}}-1}=\frac{a}{b}e\]
88where $a$, the semimajor axis, is the value of the mean equatorial radius of Earth (6,378.137 km) and $b$, the semiminor axis, is the value of the polar radius of Earth (6,356.7523142 km) \cite[pp. 25-26]{kaplan:ugpspa}.
89\subsection{Coordinate Systems}
90Now that WGS-84 is defined it is important to understand what coordinate systems can be attached to the ellipsoid and how to move between these different systems. The GPS Toolkit comes with \application{poscvt}\index{poscvt!theory}, an application that gives users the ability to easily convert coordinates in one reference frame to another. The coordinate
91systems that \application{poscvt}\index{poscvt!theory} recognizes are Cartesian (or XYZ), geodetic, geocentric, and spherical coordinates. These systems and the formulas to convert between them are discussed below.
92\subsubsection{Cartesian (XYZ) Coordinates}
93The Earth Centered Earth Fixed (ECEF) Cartesian coordinate system is fixed to the WGS-84 ellipsoid and is the common ground that makes going between the Earth Centered Inertial (ECI) reference frame used by the satellites and the systems we are used to (such as latitude, longitude, and height) manageable. The equatorial plane makes the $xy$-plane with the $+x$-axis pointing toward $0^{\circ}$ longitude and the $+y$-axis pointing toward $90^{\circ}$ E longitude. The $z$-axis is normal to the equatorial plane and points to the geographical north pole. The conversion formulas presented in the next sections will convert to and from this Cartesian reference frame, and so to convert between two non-Cartesian coordinate systems the XYZ system will be used as an intermediary~\cite[p. 24]{kaplan:ugpspa}.
94\subsubsection{Geodetic Coordinates}
95The geodetic coordinate parameters are longitude $\lambda$, latitude $\phi$, and height $h$. Longitude is defined as the angle between the position and the $x$-axis in the equatorial plane, and is easily computed given a position in Cartesian coordinates. Let a user's position $\mathbf{U}=(x_{u},y_{u},z_{u})$, then
96\[ \lambda = \left \{ \begin{array}{ll}
97\arctan \left( \frac{y_{u}}{x_{u}} \right), & \mbox{$x_{u} \geq 0$} \\
98180^{\circ} + \arctan \left( \frac{y_{u}}{x_{u}} \right), & \mbox{$x_{u} < 0$ and $y_{u} \geq 0$} \\
99-180^{\circ} +\arctan \left( \frac{y_{u}}{x_{u}} \right), & \mbox{$x_{u} < 0$ and $y_{u} < 0$}
100\end{array}
101\right. \]
102where negative angles signal west longitude.
103
104Latitude and height are not so straight forward. Latitude is determined by drawing a vector normal to the ellipsoid, beginning somewhere on the equatorial plane and terminating at the users position, we will call this the user vector. The smallest angle between this vector and the equatorial plane is the user's latitude, it is a North latitude for positive angles and South for negative. Notice that unless the user is at a pole or on the equator the vector does not pass through the center of the Earth. The users height is found by taking the magnitude of the vector originating on and normal to the ellipsoid and terminating at the user's position. Latitude $\phi$ and height $h$ are found using the following equations
105\[ \phi = \arctan\left(\frac{z_{u}+e'^{2}z_{0}}{r}\right) \]
106\[ h = U \left(1-\frac{b^{2}}{aV}\right) \]
107
108where
109
110\[ r = \sqrt{x_{u}^{2}+y_{u}^{2}} \]
111\[ E^{2} = a^{2} - b^{2} \]
112\[ F = 54 b^{2} z_{u}^{2} \]
113\[ G = r^{2} + (1-e^{2}) z_{u}^{2} - e^{2} E^{2} \]
114\[ c = \frac{e^{4} F r^{2}}{G^{3}} \]
115\[ s = \sqrt[3]{1+c+\sqrt{c^{2} + 2c}}\]
116\[ P = \frac{F}{3 \left( s + \frac{1}{s} + 1  \right)^{2}G^{2} } \]
117\[ Q = \sqrt{1+2e^{4}P} \]
118\[ r_{0} = -\frac{Pe^{2}r}{1+Q}+\sqrt{\frac{1}{2}a^{2} \left(1+\frac{1}{Q}\right)-\frac{P(1-e^{2})z_{u}^{2}}{Q(1+Q)}-\frac{1}{2}Pr^{2}}\]
119\[ U = \sqrt{(r-e^{2}r_{0})^{2}+z_{u}^{2}}\]
120\[ V = \sqrt{(r-e^{2}r_{0})^{2}+(1-e^{2})z_{u}^{2}} \]
121\[ z_{0} = \frac{b^{2}z_{u}}{aV} \]
122
123
124%\[x=(N_{h}+h)\cos\phi'\cos\lambda\]
125%\[y=(N_{h}+h)\cos\phi'\sin\lambda\]
126%\[z=(N_{h}+h-\tilde{e}^{2}N_{h})\sin\phi'\]
127%\[\tilde{e}^{2}=\tilde{f}(2-\tilde{f})\]
128%\[N_{h}=\frac{R_{e}}{(1-\tilde{e}^{2}\sin^{2}\phi')^{1/2}}\]
129%\[\tilde{f}=\frac{R_{e}-R_{p}}{R_{e}}\]
130%\[x^{2}+y^{2}+\left(\frac{R_{e}}{R_{p}}\right)^{2}z^{2}=R_{e}^{2}\]
131
132Going back to Cartesian coordinates from the geodetic system ($\lambda$ $\phi$ $h$) can be done more compactly
133\[ \mathbf{u} = \left[  \begin{array}{c}
134\frac{a\cos\lambda}{\sqrt{1+(1-e^2)\tan^{2}\phi}}+h\cos\lambda\cos\phi \\
135\frac{a\sin\lambda}{\sqrt{1+(1-e^2)\tan^{2}\phi}}+h\sin\lambda\cos\phi \\
136\frac{a(1-e^{2})\sin\phi}{\sqrt{1-e^{2}\sin^{2}\phi}}+h\sin\phi
137\end{array}
138\right] \]
139where $\mathbf{u}$ is the user's position vector~\cite[pp. 26-28, p. 76]{kaplan:ugpspa,me:gsmp}.
140
141\subsubsection{Geocentric Coordinates}
142\[x=r\cos\phi\cos\lambda\]
143\[y=r\cos\phi\sin\lambda\]
144\[z=r\sin\phi\]
145
146where $\lambda$ and $\phi$ are geocentric longitude and latitude
147
148found on page 82 in the Fundamentals of Orbital Determination paper book
149
150%\subsubsection{Spherical Coordinates}
151
152\subsubsection{Topocentric Coordinates}
153\[\mathbf{r}_{t}=T_{t}(\mathbf{r}-\mathbf{r}_{s})=T_{t}\rho\]
154
155$\mathbf{r}$ and $\mathbf{r}_{s}$ are the position vectors of the observer and satellite respectively in the Earth-fixed system
156
157\[T_{t}=\left[ \begin{array}{ccc}
158-\sin\lambda & \cos\lambda & 0 \\
159-\sin\phi\cos\lambda & -\sin\phi\sin\lambda & \cos\phi \\
160\cos\phi\cos\lambda & \cos\phi\sin\lambda & \sin\phi \end{array} \right] \]
161
162where $\lambda$ and $\phi$ are geocentric longitude and latitude
163
164found on page 84 in the Fundamentals of Orbital Determination paper book
165
166to find \emph{azimuth} (Az) and \emph{elivation} (El)
167
168\[ \begin{array}{ll}
169\sin\mbox{El}=\frac{z_{t}}{r_{t}} & -90^{\circ} \leq \mbox{El} \leq 90^{\circ} \\
170\sin\mbox{Az}=\frac{x_{t}}{r_{xy}} & \\
171\cos\mbox{Az}=\frac{y_{t}}{r_{xy}} & 0^{\circ} \leq \mbox{Az} \leq 360^{\circ}
172\end{array} \]
173
174Equations found on pages 84-85 in  Fundamentals of Orbit Determination paper book
175
176\putbib[gpstk]
177%\end{document}
178