Changing Coordinate Systems

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.
Converting Points
Two coordinate systems are related by a mapping that takes coordinate values in the old system and returns coordinate values in the new system.
CoordinateTransformData[transf,"Mapping"]
the mapping between coordinate systems as a pure function
CoordinateTransformData[transf,"Mapping",pt]
the new coordinate values of pt
CoordinateTransform[transf,pt]
the new coordinate values of pt
Converting points between two coordinate systems.
The function CoordinateTransformData returns information about mappings between the coordinate systems in CoordinateChartData.
This converts the point in polar coordinates to the corresponding Cartesian coordinates:
This converts the point in Cartesian coordinates to the corresponding values in spherical coordinates:
The mapping function can be requested from CoordinateTransformData and stored for later use:
The mapping naturally takes a single point:
Using Map, it can be applied to several points at once:
The function CoordinateTransform provides a convenient mechanism for converting one or several points.
This converts the point in spherical coordinates to the corresponding cylindrical coordinates:
The previous answer can be verified by converting both coordinate values to Cartesian coordinates:
Parameters can be specified in CoordinateTransform in the same way as in CoordinateTransformData. This converts a generic point from prolate spheroidal coordinates with parameter to hyperspherical coordinates:
Several points can be transformed at once:
Transforming Fields
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.
TransformedField[transf,f,{x1,x2,,xn}->{y1,y2,,yn}]
transform a scalar, vector, or tensor field f from coordinates xi to coordinates yi
Transforming a field between two coordinate systems.
The simpler scalar case is considered first.
This converts the scalar field from Cartesian to cylindrical coordinates:
The previous example can be done "by hand". Unlike for CoordinateTransform, for these steps to make sense, and must be coordinate names and not coordinate values such as numbers:
Parameters can be specified in TransformedField in the same way as in CoordinateTransformData. This is a transformation from cylindrical to prolate spheroidal coordinates with parameter :
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.
CoordinateTransformData[transf,prop,pt]
compute a property of the transformation at the point pt
CoordinateChartData[chart,prop,pt]
compute a property of the chart at the point pt
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: