cart2sph

From DavinciWiki
Jump to: navigation, search

Description

Convert Cartesian (rectangular) coordinates to spherical

Arguments and Return Values

Parameters: Three inputs specifying the x, y, and z values, respectively.

Return Value: An array specifying the radial, latitude, and longitude coordinates, respectively, with angles in degrees.

Usage

Syntax: cart2sph(x, y, z)

All inputs should be numeric.

These are not the conventional spherical coordinates, but they should be more useful for people doing work in planetary coordinates.

Zero longitude corresponds to the x-axis; 90 E is y-axis. Zero latitude is the equatorial (xy) plane.

This function can handle array inputs, but when entering them, you will probably want their x-dimensions to be one, so that the returned values are easier to read. The function concatenates the output coordinates along their x-axis.

When cart2sph() is entered without any arguments, it prints its description, as shown below.

Examples

dv> cart2sph()

Convert Cartesian (rectangular) coordinates to spherical
cart2sph(x, y, z) returns (r, latitude, longitude) where r is the
 radial coordinate, and latitude and longitude are in degrees.
 Returned angles are in degrees. Longitude is east-positive.
 Zero longitude corresponds to the x-axis; 90 E is y-axis.
 x, y, and z must be entered as separate arguments
 To make the output easier to read, inputs should only have one row.
S.Marshall 10-30-2009

0
dv> cart2sph(1, 1, 0)
3x1x1 array of float, bsq format [12 bytes]
1.41421353816986        0.00000000000000        45.0000000000000
dv> cart2sph(0, 0, 1)
3x1x1 array of float, bsq format [12 bytes]
1.00000000000000        90.0000000000000        0.00000000000000
dv> cart2sph(clone(-1, 1, 5), clone(1, 1, 5), cat(-sqrt(2), -1., 0., 1., sqrt(2), axis=y))
3x5x1 array of float, bsq format [60 bytes]
2.00000000000000        -45.0000000000000       135.000000000000
1.73205077648163        -35.2643890380859       135.000000000000
1.41421353816986        0.00000000000000        135.000000000000
1.73205077648163        35.2643890380859        135.000000000000
2.00000000000000        45.0000000000000        135.000000000000

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Major Sub-Functions

Related Functions

Recent Library Changes

Created On: 11-17-2009
Modified On: 11-17-2009

Personal tools