Main Content

Cartesian to Spherical

Cartesian coordinates to spherical coordinates

  • Cartesian to Spherical block

Libraries:
Simulink Extras / Transformations

Description

The Cartesian to Spherical block transforms the Cartesian coordinates (x, y, z) to the spherical coordinates (r, theta, phi).

The first input is x, the second input is y, and the third input is z. The first output is r, the second output is theta, and the third output is phi. The angles theta and phi are in radians.

The Cartesian coordinates (x, y, z) describe a point P with respect to the x-axis, y-axis, and z-axis. The spherical coordinate r is the length of the line from the origin to the point P. The spherical coordinate theta (the azimuth) is the angle measured in radians from the positive x-axis to the projection, in the x-y plane, of the line from the origin to P. The spherical coordinate phi (the zenith) is the angle, measured in radians, from the positive z-axis to the line from the origin to P.

Note

The MATLAB® function cart2sph measures phi from the x-y plane.

r=x2+y2+z2theta=arctan(yx)phi=arctan(x2+y2z)

Note

The notation for spherical coordinates might differ in other references. Sometimes, the order of theta and phi is reversed. Sometimes, theta denotes the zenith and phi denotes the azimuth.

Ports

Input

expand all

Input signal specifying the x value in the cartesian coordinates (x,y,z). All inputs must be real scalars of the same data type.

Data Types: single | double

Input signal specifying the y value in the cartesian coordinates (x,y,z). All inputs must be real scalars of the same data type.

Data Types: single | double

Input signal specifying the z value in the cartesian coordinates (x,y,z). All inputs must be real scalars of the same data type.

Data Types: single | double

Output

expand all

Output signal specifying the r coordinate of the spherical coordinates (r,theta,phi).

Data Types: single | double

Output signal specifying the theta coordinate of the spherical coordinates (r,theta,phi).

Data Types: single | double

Output signal specifying the phi coordinate of the spherical coordinates (r,theta,phi).

Data Types: single | double

Version History

Introduced in R2008b