Method on @sym: [x, y, z] = sph2cart (theta, phi, r)
Method on @sym: [x, y, z] = sph2cart (S)

Transform symbolic spherical coordinates to Cartesian coordinates.

If called with three inputs theta, phi, and r, they must be of the same shape or scalar. The shape of the outputs x, y, and z matches that of the non-scalar inputs, with scalars broadcasted appropriately.

If called with a single input S, it must be a column vector with 3 entries or a matrix with 3 columns. The column vector or each row of the matrix represents a point in spherical coordinates (theta, phi, r). If input S is a column vector, outputs x, y, and z are scalars. Otherwise, the shape of the outputs is a column vector with each row corresponding to that of the input matrix S.

Given a point (theta, phi, r) in spherical coordinates, the corresponding Cartesian coordinates are:

syms theta phi r real
[x, y, z] = sph2cart (theta, phi, r)
  ⇒ x = (sym) r⋅cos(φ)⋅cos(θ)
    y = (sym) r⋅sin(θ)⋅cos(φ)
    z = (sym) r⋅sin(φ)

See also: sph2cart, cart2sph, cart2pol, pol2cart.

Package: symbolic