Convert spherical coordinates to Cartesian XYZ coordinates.
SPH2CART(az, el, r, "degrees")
(x, y, z) = SPH2CART(az, el, r, "degrees")
az |
- |
A real or series, the azimuth in radians or degrees |
el |
- |
A real or series, the elevation in radians or degrees. |
r |
- |
Optional. A real or series, the radius. Defaults to 1.0. |
"degrees" |
- |
Optional. A string, if "degrees", all output angles are in degrees. If "radians" or not specified, the output angles are in radians. |
SPH2CART(sphcoords, "degrees")
(x, y, z) = SPH2CART(sphcoords, "degrees")
sphcoords |
- |
A 3 column series, where azimuth is the first column, elevation the second column and radius the third column. |
"degrees" |
- |
Optional. A string, if "degrees", all output angles are in degrees. If "radians" or not specified, the output angles are in radians. |
A three column series where the first column is X, the second column is Y and the third column is Z.
(x, y, z) = sph2cart(az, el, r) returns the Cartesian coordinates as separate series.
W1: sph2cart(pi/4, pi/4, 1.0)
W1 == {{0.5, 0.5, 0.707107}}
W1 transforms the spherical coordinate with azimuth at π/4 degrees, elevation of π/4 degrees and unit length. The result is a 1x3 array where the X value is 0.5, the Y value is 0.5 and the Z values is √2.
W1: sph2cart(45, 45, 1.0, "degrees")
W1 == {{0.5, 0.5, 0.707107}}
Same as above except the azimuth and elevation are specified in degrees.
W2: {{45, 45, 1.0}}
W3: sph2cart(w2, "degrees")
W3 == {{0.5, 0.5, 0.707107}}
Same as above except the input spherical coordinates are contained in a single 3 column series.
W4: {{45, 45, 1.0}}
(x, y, z) = sph2cart(w4, "degrees");
x == {0.5}
y == {0.5}
z == {0.707107}
Same as above except the output Cartesian coordinates are contained in three separate variables.
W1: {{pi/4, pi/4, 1.0}}
W2: sph2cart(w1)
W3: cart2sph(w2)
W1 == {{0.785398, 0.785398, 1.0}}
W2 == {{0.5, 0.5, 0.707107}}
W3 == {{0.785398, 0.785398, 1.0}}
Demonstrates that SPH2CART and CART2SPH are inverse functions.
SPH2CART transforms azimuth, elevation and radius coordinates to Cartesian XYZ coordinates.
Azimuth (az) is measured counterclockwise from the positive X axis in the X-Y plane. Azimuth is in radians unless "degrees" is specified. Azimuth varies from 0 to 2π radians or 0 to 360 degrees.
Elevation (el) is measured from the X-Y plane. Elevation is in radians unless "degrees" is specified. Elevation varies from -π/2 to π/2 radians or -90 to 90 degrees.
Radius (r) is the optional length of the 3D vector. Defaults to unity.
If "degrees" is specified, the output azimuth and elevation angles are in degrees. If "radians" or not specified, azimuth and elevation are in radians.