cspice_latrec

 Abstract I/O Examples Particulars Required Reading Version Index_Entries

#### Abstract

```
CSPICE_LATREC converts latitudinal coordinates to rectangular
(Cartesian) coordinates.

```

#### I/O

```
Given:

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

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

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

the call:

rectan = cspice_latrec( radius, lon, lat)

returns:

rectan   the array(s) containing the rectangular coordinates of the
position or set of positions

[3,n] = size(rectan); double = class(rectan)

'rectan' returns with the same units associated with 'radius'.

'rectan' returns with the vectorization measure, N, as

```

#### 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.
%

%
% Convert the latitudinal to rectangular.
%

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

MATLAB outputs:

1.0e-14 *

-0.01996090072080  -0.05552320600838   0.63783453323816
0.02182376758148                  0  -0.01531271963894
0.01912147275010   0.01213804257114   0.02039513446643

Example (2):

%
% Define eleven sets of latitudinal coordinates.
%
r         = [ 0., 1., 1., 1., 1., 1., 1., ...
sqrt(2), sqrt(2), sqrt(2), sqrt(3) ];
longitude = [ 0., 0., 90., 0. 180., -90., ...
0., 45., 0., 90., 45. ];
latitude  = [ 0., 0., 0., 90., 0., 0.,    ...
-90., 0., 45., 45., 35.2643 ];

%
% ...convert the latitudinal coordinates to rectangular coordinates
%
longitude = longitude * cspice_rpd;
latitude  = latitude  * cspice_rpd;

rectan = cspice_latrec(r, longitude, latitude);

%
% Loop over each set of coordinates for output, convert 'longitude'
% and 'latitude' to degrees...
%
longitude = longitude * cspice_dpr;
latitude  = latitude  * cspice_dpr;

%
% Create an array of values for output.
%
output = [ r; longitude; latitude; rectan ];

%
% Output banner.
%
disp('     r       longitude  latitude       x         y           z   ')
disp('  --------   --------   --------   --------   --------   --------')

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:

r       longitude  latitude       x         y           z
--------   --------   --------   --------   --------   --------
0.0000     0.0000     0.0000     0.0000     0.0000     0.0000
1.0000     0.0000     0.0000     1.0000     0.0000     0.0000
1.0000    90.0000     0.0000     0.0000     1.0000     0.0000
1.0000     0.0000    90.0000     0.0000     0.0000     1.0000
1.0000   180.0000     0.0000    -1.0000     0.0000     0.0000
1.0000   -90.0000     0.0000     0.0000    -1.0000     0.0000
1.0000     0.0000   -90.0000     0.0000     0.0000    -1.0000
1.4142    45.0000     0.0000     1.0000     1.0000     0.0000
1.4142     0.0000    45.0000     1.0000     0.0000     1.0000
1.4142    90.0000    45.0000     0.0000     1.0000     1.0000
1.7321    45.0000    35.2643     1.0000     1.0000     1.0000

```

#### Particulars

```
None.

```

```
For important details concerning this module's function, please refer to
the CSPICE routine latrec_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 rectangular coordinates

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