Changing coordinate systems can involve two very different operations. One is recomputing coordinate values that correspond to the same point. The other is re-expressing a field in terms of new variables. The Wolfram Language provides functions to perform both these operations.
Two coordinate systems are related by a mapping that takes coordinate values in the old system and returns coordinate values in the new system.
When transforming fields between two coordinate systems, a field given in terms of variables in the old system is re-expressed in terms of variables in the new system. In addition to the mapping between the systems, several additional steps are needed: solving for the old variables in terms of the new, substituting in these expressions, and, in the case of vector and tensor fields, accounting for differences in basis vectors between the two coordinate systems. All of these steps are performed by the command TransformedField.
The vector and tensor case is more complicated because of the need to account for the change of basis vectors. As a result, the transformation of a vector is not merely the transformation of its components. For arrays, which are interpreted as components in an orthonormal basis, the rotation matrix that relates the two bases is given by the CoordinateTransformData property "OrthonormalBasisRotation".
This converts the vector field from Cartesian coordinates to spherical coordinates, producing the manifestly radial result :
Two pieces of information are needed to reproduce the previous example: the variable replacement rules, as in the scalar case, and the basis rotation matrix. Since the rotation matrix specifies the rotation between bases, its transpose is the matrix that acts on components:
To transform a vector between coordinate systems, first the vector is multiplied by the rotation matrix to change components in the basis to components in the basis (equivalently, the projection of the vector onto the local basis vectors). Subsequently, the replacement rules are applied:
Using Map, lists of scalar fields can be transformed between coordinates. The result is quite different from transforming a vector field with the same components:
This transforms the vector field from spherical to Cartesian coordinates:
The vector field in hyperspherical coordinates with the same local components is in fact a rotational vector field about the axis:
Parameters for coordinate systems can be specified in TransformedField. This converts the vector field from Cartesian coordinates to prolate spheroidal coordinates with parameter :
This transforms a rank-2 tensor from Cartesian to polar coordinates:
Using Map, it is possible to transform the matrix as a list of two vectors or as a matrix of four scalar fields. The results are quite different in each case:
Relating Orthonormal Bases
The basis rotation matrix used above combines information about both the Jacobian matrix of the mapping and the orthonormal basis in each chart. For orthogonal coordinate systems, it is constructed from the Jacobian and the two sets of scale factors.
Computing properties of charts and transformations.
The matrix rotates the basis vectors into the basis vectors :
The rotated vector is in the basis, and is in that same basis:
To compute the rotation matrix, the scale factors, which define the orthonormal bases in orthogonal systems, are needed. Notice that CoordinateTransform is used to ensure both sets of scale factors are evaluated at the same point:
The rotation matrix is constructed from the transposed Jacobian matrix by conjugating it with diagonal matrices containing the scale factors:
This is the matrix that rotates the cylindrical basis vectors into the spherical basis vectors :
The matrix rotates into , which is , and it rotates into , which is the same as :
This rotation matrix can be constructed using the scale factors and the Jacobian matrix in the same manner as before: