Routines (alphabetical) > Routines: C > CV_COORD

# CV_COORD

The CV_COORD function converts 2D and 3D coordinates between the rectangular, polar, cylindrical, and spherical coordinate systems.

This routine is written in the IDL language. Its source code can be found in the file `cv_coord.pro` in the `lib` subdirectory of the IDL distribution.

## Examples

Convert from spherical to cylindrical coordinates:

sph_coord = [[45.0, -60.0, 10.0], [0.0, 0.0, 0.0]]

rect_coord = CV_COORD(FROM_SPHERE=sph_coord, /TO_CYLIN, /DEGREES)

Convert from rectangular to polar coordinates:

rect_coord = [10.0, 10.0]

polar_coord = CV_COORD(FROM_RECT=rect_coord, /TO_POLAR)

## Syntax

Result = CV_COORD( [, /DEGREES] [, /DOUBLE] [, FROM_CYLIN=cyl_coords | , FROM_POLAR=pol_coords | , FROM_RECT=rect_coords | , FROM_SPHERE=sph_coords] [, /TO_CYLIN | , /TO_POLAR | , /TO_RECT | , /TO_SPHERE] )

## Return Value

If the value specified in the “FROM_” keyword is double precision, or if the DOUBLE keyword is set, then all calculations are performed in double precision and the returned value is double precision. Otherwise, single precision is used. If none of the “FROM_” keyword are specified, 0 is returned. If none of the “TO_” keywords are specified, the input coordinates are returned.

## Arguments

This function has no required arguments. All data is passed in via keywords.

## Keywords

### DEGREES

If set, then the input and output coordinates are in degrees (where applicable). Otherwise, the angles are in radians.

### DOUBLE

Set this keyword to force the computation to be done in double-precision arithmetic.

### FROM_CYLIN

A vector of the form [angle, radius, z], or a (3, n) array of cylindrical coordinates to convert.

### FROM_POLAR

A vector of the form [angle, radius], or a (2, n) array of polar coordinates to convert.

### FROM_RECT

A vector of the form [x, y] or [x, y, z], or a (2, n) or (3, n) array containing rectangular coordinates to convert.

### FROM_SPHERE

A vector of the form [longitude, latitude, radius], or a (3, n) array of spherical coordinates to convert.

### TO_CYLIN

If set, cylindrical coordinates are returned in a vector of the form [angle, radius, z], or a (3, n) array.

### TO_POLAR

If set, polar coordinates are returned in a vector of the form [angle, radius], or a (2, n) array.

### TO_RECT

If set, rectangular coordinates are returned in a vector of the form [x, y] or [x, y, z], or a (2, n) or (3, n) array.

### TO_SPHERE

If set, spherical coordinates are returned in a vector of the form [longitude, latitude, radius], or a (3, n) array.

## Version History

Pre 4.0 | Introduced

## See Also

COORD2TO3, CROSSP