cspice_latsph

 Abstract I/O Examples Particulars Required Reading Version Index_Entries

#### Abstract

```
CSPICE_LATSPH converts latitudinal coordinates to spherical
coordinates.

```

#### I/O

```
Given:

radius   the value(s) describing the distance of the position
from the origin.

[1,n] = size(radius); double = class(radius)

lon      the value(s) describing the angle of the position from
the XZ plane measured in radians.

[1,n] = size(lon); double = class(lon)

lat      the value(s) describing the angle of the position from the
XY plane measured in radians.

[1,n] = size(lat); double = class(lat)

the call:

[rho, colat, lons] = cspice_latsph( radius, lon, lat)

returns:

rho      the value(s) describing the distance of the position
from the origin.

[1,n] = size(rho); double = class(rho)

colat    the value(s) describing the angle between the point and the
positive z-axis, measured in radians (also referred to
as the polar angle).

[1,n] = size(colat); double = class(colat)

lons     the value(s) describing the angle of the projection of the
point to the XY plane from the positive X-axis, measured
in radians, with range:

-pi < lons <= pi

The positive Y-axis is at longitude PI/2 radians.

[1,n] = size(lons); double = class(lons)

The argument 'rho' returns in the same units associated
with 'radius'.

'rho', 'colat', and 'lons' return with the same vectorization
measure, N, as 'radius', 'lon', and 'lat'.

```

#### Examples

```
Any numerical results shown for this example may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.

Example (1):

%
% Load an SPK, leapseconds, and PCK kernel set.
%
cspice_furnsh( 'standard.tm' )

%
% Create a vector of scalar times.
%
et = [0:2]*2.*cspice_spd;

%
% Retrieve the position of the moon seen from earth at 'et'
% in the J2000 frame without aberration correction.
%
[pos, et] = cspice_spkpos( 'MOON', et, 'J2000', 'NONE', 'EARTH' );

%
% Convert the array of position vectors 'pos' to latitudinal
% coordinates.
%
[radius, longitude, latitude] = cspice_reclat(pos);

%
% Convert the latitudinal coords to spherical.
%
[rho, colat, lon] = cspice_latsph( radius, longitude, latitude);

%
% Convert the spherical to rectangular.
%
[rectan] = cspice_sphrec(radius, colat, lon);

%
% Calculate the relative error against the original position
% vectors.
%
(rectan-pos) ./ pos

MATLAB outputs:

1.0e-14 *

0  -0.03701547067225   0.63783453323816
0.02182376758148   0.01641520435413  -0.01531271963894
-0.01912147275010  -0.04855217028457   0.02039513446643

The relative error between the original array of position vectors
and those that resulted from the various coordinate conversion
has magnitude on the order of 10^(-14).

Example (2):

%
% Define six sets of latitudinal coordinates, 'lon' and 'lat'
% expressed in degrees - converted to radians by use
% of cspice_rpd.
%
rad = [ 1.,  1., sqrt(2.), sqrt(2.),   1.,  0. ];
lon = [ 0., 90.,     180.,     180., 180., 33. ] * cspice_rpd;
lat = [ 0.,  0.,      45.,      -45., 90.,  0. ] * cspice_rpd;

%
% ...convert the latitudinal coordinates to spherical coordinates
%
[rho, colat, slon] = cspice_latsph(rad, lon, lat);

%
% ...convert angular measure to degrees.
%
colat = colat * cspice_dpr;
lon   = lon   * cspice_dpr;
slon  = slon  * cspice_dpr;
lat   = lat   * cspice_dpr;

%
% Output banner.
%
disp('    rho       colat       slon       rad        lon        lat   ')
disp('  --------   --------   --------   --------   --------   --------')

%
% Create an array of values for output.
%
output = [ rho; colat; slon; rad; lon; lat];
txt    = sprintf( '%10.4f %10.4f %10.4f %10.4f %10.4f %10.4f\n', ...
output );
disp( txt )

%
% It's always good form to unload kernels after use,
% particularly in MATLAB due to data persistence.
%
cspice_kclear

MATLAB outputs:

rho       colat       slon       rad        lon        lat
--------   --------   --------   --------   --------   --------
1.0000    90.0000     0.0000     1.0000     0.0000     0.0000
1.0000    90.0000    90.0000     1.0000    90.0000     0.0000
1.4142    45.0000   180.0000     1.4142   180.0000    45.0000
1.4142   135.0000   180.0000     1.4142   180.0000   -45.0000
1.0000     0.0000   180.0000     1.0000   180.0000    90.0000
0.0000    90.0000    33.0000     0.0000    33.0000     0.0000

```

```
None.

```

#### Required Reading

```
For important details concerning this module's function, please refer to
the CSPICE routine latsph_c.

MICE.REQ

```

#### Version

```
-Mice Version 1.0.1, 01-DEC-2014, EDW (JPL)

Edited I/O section to conform to NAIF standard for Mice documentation.

-Mice Version 1.0.0, 22-NOV-2005, EDW (JPL)

```

#### Index_Entries

```
latitudinal to spherical coordinates

```
`Wed Apr  5 18:00:33 2017`