Version:

Last Modified: March 15, 2017

Transforms 3D Cartesian coordinates into spherical data. This function works element-wise for arrays.

[a, b, c] = cart_to_sphere(x, y, z)Legacy name: cart2sph

X-coordinates. x is a scalar or an array of any dimension of floating-point or real numbers.

Y-coordinates. y is a scalar or an array of any dimension of floating-point or real numbers of the same shape as x.

Z-coordinates. z is a scalar or an array of any dimension of floating-point or real numbers of the same shape as x.

Azimuthal angles, or the angles measured from the x-axis to the data points projected in the xy-plane. a is an array of the same size as the maximum shape of x, y, and z.

Elevation angles, or the angles measured from the xy-plane to the data points. b is an array of the same size as the maximum shape of x, y, and z.

Radii of the spherical data. c is an array of the same size as the maximum shape of x, y, and z.

MathScript performs the transformation using the following equations:

a = atan2(y, x)

b = atan2(z, sqrt(x.^2+y.^2))

c = sqrt(x.^2+y.^2+z.^2)

[A, B, C] = cart_to_sphere(1, 1, 1)

**Where This Node Can Run: **

Desktop OS: Windows

FPGA: This product does not support FPGA devices