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. Mathematica 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.
In[6]:=
Click for copyable input
Out[6]=
This converts the point in Cartesian coordinates to the corresponding values in spherical coordinates.
In[7]:=
Click for copyable input
Out[7]=
The mapping function can be requested from CoordinateTransformData and stored for later use.
In[8]:=
Click for copyable input
Out[8]=
The mapping naturally takes a single point.
In[9]:=
Click for copyable input
Out[9]=
Using Map, it can be applied to several points at once.
In[10]:=
Click for copyable input
Out[10]=

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.
In[11]:=
Click for copyable input
Out[11]=
The previous answer can be verified by converting both coordinate values to Cartesian coordinates.
In[12]:=
Click for copyable input
Out[12]=
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.
In[13]:=
Click for copyable input
Out[13]=
Several points can be transformed at once.
In[14]:=
Click for copyable input
Out[14]=

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 to coordinates

Transforming a field between two coordinate systems.

The simpler scalar case is considered first.

This converts the scalar field from Cartesian to cylindrical coordinates.
In[15]:=
Click for copyable input
Out[15]=
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.
In[16]:=
Click for copyable input
Out[16]=
In[17]:=
Click for copyable input
Out[17]=
In[18]:=
Click for copyable input
Out[18]=
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 .
In[19]:=
Click for copyable input
Out[19]=

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 .

This converts the vector field from Cartesian coordinates to spherical coordinates, producing the manifestly radial result .
In[20]:=
Click for copyable input
Out[20]=
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.
In[21]:=
Click for copyable input
Out[21]=
In[22]:=
Click for copyable input
Out[22]=
In[23]:=
Click for copyable input
Out[23]=
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.
In[24]:=
Click for copyable input
Out[24]=
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.
In[25]:=
Click for copyable input
Out[25]=
In[26]:=
Click for copyable input
Out[26]=
This transforms the vector field from spherical to Cartesian coordinates.
In[27]:=
Click for copyable input
Out[27]=
The vector field in hyperspherical coordinates with the same local components is in fact a rotational vector field about the axis.
In[28]:=
Click for copyable input
Out[28]=
Parameters for coordinate systems can be specified in TransformedField. This converts the vector field from Cartesian coordinates to prolate spheroidal coordinates with parameter .
In[29]:=
Click for copyable input
Out[29]=
This transforms a rank-2 tensor from Cartesian to polar coordinates.
In[30]:=
Click for copyable input
Out[30]=
In[31]:=
Click for copyable input
Out[31]=
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.
In[32]:=
Click for copyable input
Out[32]=
In[33]:=
Click for copyable input
Out[33]=

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 .
In[34]:=
Click for copyable input
Out[34]=
The rotated vector is in the basis, and is in that same basis.
In[35]:=
Click for copyable input
Out[35]=
In[36]:=
Click for copyable input
Out[36]=
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.
In[37]:=
Click for copyable input
Out[37]=
In[38]:=
Click for copyable input
Out[38]=
The rotation matrix is constructed from the transposed Jacobian matrix by conjugating it with diagonal matrices containing the scale factors.
In[39]:=
Click for copyable input
Out[39]=
In[40]:=
Click for copyable input
Out[40]=
This is the matrix that rotates the cylindrical basis vectors into the spherical basis vectors .
In[43]:=
Click for copyable input
Out[43]=
The matrix rotates into , which is , and it rotates into , which is the same as .
In[44]:=
Click for copyable input
Out[44]=
In[45]:=
Click for copyable input
Out[45]=
This rotation matrix can be constructed using the scale factors and the Jacobian matrix in the same manner as before.
In[46]:=
Click for copyable input
Out[46]=
In[47]:=
Click for copyable input
Out[47]=
In[48]:=
Click for copyable input
Out[48]=
In[49]:=
Click for copyable input
Out[49]=
New to Mathematica? Find your learning path »
Have a question? Ask support »