Coordinate Systems

Hemispherical coordinates are essentially spherical coordinates restricted to the non-negative half-space defined by a differential surface’s normal.

../../../../_images/hemispherical-coordinates.svg

Fig. 1 \(\phi \in [0, 2 \pi]\) represents the azimuth and is measured typically from the \(X\) axis; \(\theta \in [0, \pi / 2]\) gives the elevation and starts from the normal vector \(N_x\) at a surface point \(x\).

Notice that Fig. 1 depicts \((\theta, \phi)\) in a right-handed coordinate system where counterclockwise rotations are positive.

../../../../_images/left-handedness.svg

Fig. 2 Left-handed Coordinate System

../../../../_images/right-handedness.svg

Fig. 3 Right-handed Coordinate System

In terms of mapping \(Y \rightarrow Z\), \(Z \rightarrow X\), and \(X \rightarrow Y\), the two coordinate systems are equivalent, so the important thing is being consistent with the coordinate system at hand. Fig. 2 is assumed in some software packages (e.g. RenderMan) while Fig. 3 is favored by graphics APIs (e.g. OpenGL, Vulkan). Before delving into coordinate system transformations, it will be helpful to have some examples to work with.

Cylindrical Coordinates

../../../../_images/cylindrical-coordinates.svg

Fig. 4 Adapted from [Dawa].

Fig. 4 is an extension of polar coordinates into three dimensions. The Cartesian coordinates of cylindrical coordinates are defined as

(1)\[\begin{split}x_c &= r \cos \phi\\ y_c &= y\\ z_c &= r \sin \phi.\end{split}\]

Notice that \(\phi\) will start from the \(X\)-axis and sweep towards the \(Z\)-axis by convention of polar coordinates. The inverse transformation is then

\[\begin{split}x_c^2 + z_c^2 &= r^2 (\cos^2 \phi + \sin^2 \phi) = r^2\\ \frac{z_c}{x_c} &= \tan \phi\\ y_c &= y.\end{split}\]

Spherical Coordinates

../../../../_images/spherical-coordinates.svg

Fig. 5 Adapted from [Dawb].

One intuitive way to think about Fig. 5 is to relate it to Fig. 4 since they share the azimuthal angle \(\phi\). The cylindrical coordinates of spherical coordinates are defined as

(2)\[\begin{split}r &= \rho \sin \theta\\ y &= \rho \cos \theta.\end{split}\]

Substituting (2) into (1) yields

(3)\[\begin{split}x_c &= r \cos \phi = \rho \sin \theta \cos \phi\\ y_c &= y = \rho \cos \theta\\ z_c &= r \sin \phi = \rho \sin \theta \sin \phi.\end{split}\]

The inverse transformation from Cartesian to spherical coordinates is then

\[\begin{split}x_c^2 + z_c^2 + y_c^2 &= \rho^2 \sin^2 \theta (\cos^2 \phi + \sin^2 \phi) + \rho^2 \cos^2 \theta = \rho^2 (\cos^2 \theta + \sin^2 \theta) = \rho^2\\ \frac{z_c}{x_c} &= \tan \phi\\ \frac{\sqrt{x_c^2 + z_c^2}}{y_c} &= \tan \theta.\end{split}\]

Change of Coordinates

A vector space over a field \(F\) is a set \(V\) together with the operations of addition and multiplication that adheres to eight axioms. The elements of \(V\) and \(F\) are commonly called vectors and scalars respectively. A set \(\beta = \{ \mathbf{b}_1, \mathbf{b}_2, \ldots, \mathbf{b}_n \} \subset V\) is a basis if it satisfies the following properties:

Linear Independence

For all \(x_1, x_2, \ldots, x_n \in F\), if \(x_1 \mathbf{b}_1 + x_2 \mathbf{b}_2 + \cdots + x_n \mathbf{b}_n = \boldsymbol{0}\), then \(x_1 = x_2 = \cdots = x_n = 0\).

Linear Span

The coordinates of a vector \(\mathbf{v} \in V\) are those coefficients \(c_1, c_2, \ldots, c_n \in F\) which uniquely express \(\mathbf{v} = c_1 \mathbf{b}_1 + c_2 \mathbf{b}_2 + \cdots + c_n \mathbf{b}_n\).

Suppose \(\beta\) is a basis of \(V\). The dimension of \(V\), denoted as \(\text{dim}_F(V)\), is the cardinality of \(\beta\) and represents the maximum number of linearly independent vectors, which in this case is \(n\). In an \(n\)-dimensional vector space, any set of \(n\) linearly independent vectors form a basis for the space.

[Joy] denotes the column vector of these coordinates as

\[[\mathbf{v}]_\beta = \begin{bmatrix} c_1 & c_2 & \cdots & c_n \end{bmatrix}^\top.\]

Let \(\gamma = \{ \mathbf{g}_1, \mathbf{g}_2, \ldots, \mathbf{g}_n \}\) denote another basis of \(V\). Observe that

\[\begin{split}[\mathbf{v}]_\gamma = [c_1 \mathbf{b}_1 + c_2 \mathbf{b}_2 + \cdots + c_n \mathbf{b}_n]_\gamma = c_1 [\mathbf{b}_1]_\gamma + c_2 [\mathbf{b}_2]_\gamma + \cdots + c_n [\mathbf{b}_n]_\gamma = \begin{bmatrix} [\mathbf{b}_1]_\gamma & [\mathbf{b}_2]_\gamma & \cdots & [\mathbf{b}_n]_\gamma \end{bmatrix} \begin{bmatrix} c_1\\ c_2\\ \vdots \\ c_n \end{bmatrix} = P_{\gamma \leftarrow \beta} [\mathbf{v}]_\beta\end{split}\]

where \(P_{\gamma \leftarrow \beta}\) represents the transition matrix whose columns are coordinates of \(\mathbf{b}_{1 \leq j \leq n}\) in basis \(\gamma\) [Min]. Therefore, the transition matrix \(P_{\gamma \leftarrow \beta}\) converts from \(\beta\)-coordinates to \(\gamma\)-coordinates.

To find the coordinates of \(\mathbf{b}_j\) in basis \(\gamma\), one needs to express \(\mathbf{b}_j\) as a linear combination of the \(\gamma\)-basis vectors i.e. solve the linear system

\[\mathbf{b}_j = \begin{bmatrix} \mathbf{g}_1 & \mathbf{g}_2 & \cdots & \mathbf{g}_n \end{bmatrix} \mathbf{x} = x_1 \mathbf{g}_1 + x_2 \mathbf{g}_2 + \cdots + x_n \mathbf{g}_n\]

[Bura]. The solution set to each system can be computed via reducing the associated augmented matrix \(\begin{bmatrix} \mathbf{g}_1 & \mathbf{g}_2 & \cdots & \mathbf{g}_n & \mid & \mathbf{b}_j \end{bmatrix}\) to echelon form, which can be accomplished through Gaussian-Jordan elimination [Burb]. Notice that when \(\mathbf{b}_j = \boldsymbol{0}\), solving for the linear system is equivalent to testing for linear independence. Since both the \(\gamma\)-basis and \(\beta\)-basis vectors are fixed i.e. not varying, one can compute the solution set for all the systems simultaneously by producing the reduced echelon form of

\[\begin{bmatrix} \mathbf{g}_1 & \mathbf{g}_2 & \cdots & \mathbf{g}_n & \mid & \mathbf{b}_1 & \mid & \mathbf{b}_2 & \mid & \cdots & \mid & \mathbf{b}_n \end{bmatrix}.\]

When the \(\beta\)-basis vectors are varying, reframing the problem as

\[\begin{bmatrix} \mathbf{g}_1 & \mathbf{g}_2 & \cdots & \mathbf{g}_n \end{bmatrix} \begin{bmatrix} \mathbf{x}_1 & \mathbf{x}_2 & \cdots & \mathbf{x}_n \end{bmatrix} = \begin{bmatrix} \mathbf{b}_1 & \mathbf{b}_2 & \cdots & \mathbf{b}_n \end{bmatrix}.\]

and applying LU factorization instead of Gaussian-Jordan elimination results in less computation. Evidently, when \(\gamma = \beta\), the transition matrix must be the identity matrix to satisfy \([\mathbf{v}]_\beta = P_{\beta \leftarrow \beta} [\mathbf{v}]_\beta\).

Let \(\epsilon = \{ \mathbf{e}_1, \mathbf{e}_2, \ldots, \mathbf{e}_n \}\) denote the standard basis. When \(\gamma = \epsilon\), the augmented matrix is already in reduced echelon form. Hence the transition matrix

\[P_{\epsilon \leftarrow \beta} = \begin{bmatrix} \mathbf{b}_1 & \mathbf{b}_2 & \cdots & \mathbf{b}_n \end{bmatrix}.\]

Since the transition matrices \(P_{\epsilon \leftarrow \gamma}\) and \(P_{\epsilon \leftarrow \beta}\) have linearly independent columns,

\[P_{\gamma \leftarrow \beta} = P_{\gamma \leftarrow \epsilon} P_{\epsilon \leftarrow \beta} = (P_{\epsilon \leftarrow \gamma})^{-1} P_{\epsilon \leftarrow \beta}.\]

Applying Change of Coordinates

Some derivations define cylindrical coordinates (1) and spherical coordinates (3) as

\[\begin{split}x_c &= r \cos \phi\\ y_c &= r \sin \phi\\ z_c &= z,\end{split}\]

and

\[\begin{split}x &= r \sin \theta \cos \phi\\ y &= r \sin \theta \sin \phi\\ z &= r \cos \theta\end{split}\]

respectively, which is essentially defining

\[P_{\epsilon \leftarrow \beta} = \begin{bmatrix} \mathbf{e}_1 & \mathbf{e}_3 & \mathbf{e}_2 \end{bmatrix}.\]

Likewise, Fig. 2 can be converted to Fig. 3 by using the transition matrix

\[P_{\epsilon \leftarrow \gamma} = \begin{bmatrix} \mathbf{e}_1 & \mathbf{e}_2 & -\mathbf{e}_3 \end{bmatrix}.\]

References

Bura

James V. Burke. Math 308 review. https://www.math.washington.edu/ burke/crs/407/308rev/308rev.pdf. Accessed: 2016-10-06.

Burb

James V. Burke. Matrices, block structures and gaussian elimination. https://www.math.washington.edu/ burke/crs/407/notes/LA-and-blocks.pdf. Accessed: 2016-10-06.

Dawa

Paul Dawkins. Cylindrical coordinates. http://tutorial.math.lamar.edu/Classes/CalcIII/CylindricalCoords.aspx. Accessed: 2016-10-06.

Dawb

Paul Dawkins. Spherical coordinates. http://tutorial.math.lamar.edu/Classes/CalcIII/SphericalCoords.aspx. Accessed: 2016-10-06.

Joy

David E. Joyce. Change of coordinates. http://aleph0.clarku.edu/ djoyce/ma130/change.pdf. Accessed: 2016-10-06.

Min

Andrey Minchenko. Transition matrix. http://www.math.cornell.edu/ andreim/Lec26.pdf. Accessed: 2016-10-06.