Table of contents
CSPICE_LATREC converts latitudinal coordinates to rectangular
(Cartesian) coordinates.
Given:
radius the distance of a point from the origin, or an N-vector of
distances.
help, radius
DOUBLE = Scalar or DOUBLE = Array[N]
lon the longitude of the input point, or an N-vector of
longitudes.
help, lon
DOUBLE = Scalar or DOUBLE = Array[N]
This is the angle between the prime meridian and the meridian
containing the point. The direction of increasing longitude is
from the +X axis towards the +Y axis.
Longitude is measured in radians. On input, the
range of longitude is unrestricted.
lat the latitude of the input point, or an N-vector of
latitudes.
help, lat
DOUBLE = Scalar or DOUBLE = Array[N]
This is the angle from the XY plane of the ray from the origin
through the point.
Latitude is measured in radians. On input, the range
of latitude is unrestricted.
the call:
cspice_latrec, radius, lon, lat, rectan
returns:
rectan the rectangular coordinates of the input point, or an N-vector
of coordinates.
help, rectan
DOUBLE = Array[3] or DOUBLE = Array[3,N]
`rectan' is a 3-vector.
The units associated with `rectan' are those
associated with the input `radius'.
None.
Any numerical results shown for these examples may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
1) Compute the latitudinal coordinates of the position of the
Moon as seen from the Earth, and convert them to rectangular
coordinates.
Use the meta-kernel shown below to load the required SPICE
kernels.
KPL/MK
File name: latrec_ex1.tm
This meta-kernel is intended to support operation of SPICE
example programs. The kernels shown here should not be
assumed to contain adequate or correct versions of data
required by SPICE-based user applications.
In order for an application to use this meta-kernel, the
kernels referenced here must be present in the user's
current working directory.
The names and contents of the kernels referenced
by this meta-kernel are as follows:
File name Contents
--------- --------
de421.bsp Planetary ephemeris
naif0012.tls Leapseconds
\begindata
KERNELS_TO_LOAD = ( 'de421.bsp',
'naif0012.tls' )
\begintext
End of meta-kernel
Example code begins here.
PRO latrec_ex1
;;
;; Load SPK and LSK kernels, use a meta kernel for
;; convenience.
;;
cspice_furnsh, 'latrec_ex1.tm'
;;
;; Look up the geometric state of the Moon as seen from
;; the Earth at 2017 Mar 20, relative to the J2000
;; reference frame.
;;
cspice_str2et, '2017 Mar 20', et
cspice_spkpos, 'Moon', et, 'J2000', 'NONE', 'Earth', pos, ltime
;;
;; Convert the position vector `pos' to latitudinal
;; coordinates.
;;
cspice_reclat, pos, radius, lon, lat
;;
;; Convert the latitudinal to rectangular coordinates.
;;
cspice_latrec, radius, lon, lat, rectan
print, ' '
print, 'Original rectangular coordinates:'
print, ' '
print, format='(A,F20.8)', ' X (km): ', pos[0]
print, format='(A,F20.8)', ' Y (km): ', pos[1]
print, format='(A,F20.8)', ' Z (km): ', pos[2]
print, ' '
print, 'Latitudinal coordinates:'
print, ' '
print, format='(A,F20.8)', ' Radius (km): ', radius
print, format='(A,F20.8)', ' Longitude (deg): ', lon*cspice_dpr( )
print, format='(A,F20.8)', ' Latitude (deg): ', lat*cspice_dpr( )
print, ' '
print, 'Rectangular coordinates from cspice_latrec:'
print, ' '
print, format='(A,F20.8)', ' X (km): ', rectan[0]
print, format='(A,F20.8)', ' Y (km): ', rectan[1]
print, format='(A,F20.8)', ' Z (km): ', rectan[2]
print, ' '
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Original rectangular coordinates:
X (km): -55658.44323296
Y (km): -379226.32931475
Z (km): -126505.93063865
Latitudinal coordinates:
Radius (km): 403626.33912495
Longitude (deg): -98.34959789
Latitude (deg): -18.26566077
Rectangular coordinates from cspice_latrec:
X (km): -55658.44323296
Y (km): -379226.32931475
Z (km): -126505.93063865
2) Create a table showing a variety of latitudinal coordinates
and the corresponding rectangular coordinates.
Corresponding latitudinal and rectangular coordinates are
listed to three decimal places. Input angles are in degrees.
Example code begins here.
PRO latrec_ex2
;;
;; Define eleven sets of latitude coordinates, `longitude'
;; and `latitude' expressed in degrees.
;;
radius = [ 0d, 1d, 1d , 1d , 1d , 1d, $
1d, 1.4142d, 1.4142d, 1.4142d, 1.732d ]
longitude= [ 0d, 0d, 90d, 0d , 180d, -90d, $
0d, 45d , 0d , 90d , 45d ]
latitude = [ 0d, 0d, 0d , 90d, 0d , 0d, $
-90d, 0d , 45d , 45d , 35.2643d ]
lon_rad = longitude * cspice_rpd()
lat_rad = latitude * cspice_rpd()
;;
;; Convert the coordinates from latitudinal to rectangular.
;;
cspice_latrec, radius, lon_rad, lat_rad, rectan
;;
;; Print a header for the data output.
;;
print, ' radius lon lat ', $
' rect[0] rect[1] rect[2]'
print, ' ------- ------- -------', $
' ------- ------- -------'
;;
;; Load the data for easy output.
;;
output = dblarr( 6, 11 )
output[0,*] = radius
output[1,*] = longitude
output[2,*] = latitude
output[3,*] = rectan[0,*]
output[4,*] = rectan[1,*]
output[5,*] = rectan[2,*]
;;
;; Output the coordinate table.
;;
print, FORMAT='(6D9.3)', output
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
radius lon lat rect[0] rect[1] rect[2]
------- ------- ------- ------- ------- -------
0.000 0.000 0.000 0.000 0.000 0.000
1.000 0.000 0.000 1.000 0.000 0.000
1.000 90.000 0.000 0.000 1.000 0.000
1.000 0.000 90.000 0.000 0.000 1.000
1.000 180.000 0.000 -1.000 0.000 0.000
1.000 -90.000 0.000 0.000 -1.000 0.000
1.000 0.000 -90.000 0.000 0.000 -1.000
1.414 45.000 0.000 1.000 1.000 0.000
1.414 0.000 45.000 1.000 0.000 1.000
1.414 90.000 45.000 0.000 1.000 1.000
1.732 45.000 35.264 1.000 1.000 1.000
This routine returns the rectangular coordinates of a point
whose position is input in latitudinal coordinates.
Latitudinal coordinates are defined by a distance from a central
reference point, an angle from a reference meridian, and an angle
above the equator of a sphere centered at the central reference
point.
1) If any of the input arguments, `radius', `lon' or `lat', is
undefined, an error is signaled by the IDL error handling
system.
2) If any of the input arguments, `radius', `lon' or `lat', is
not of the expected type, or it does not have the expected
dimensions and size, an error is signaled by the Icy
interface.
3) If the input vectorizable arguments `radius', `lon' and `lat'
do not have the same measure of vectorization (N), an error is
signaled by the Icy interface.
4) If the output argument `rectan' is not a named variable, an
error is signaled by the Icy interface.
None.
None.
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.2.0, 13-AUG-2021 (JDR)
Edited the header to comply with NAIF standard. Added complete
code examples.
Changed the input argument names "longitude" and "latitude" to
"lon" and "lat" for consistency with other routines.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections, and
completed -Particulars section.
Removed reference to the routine's corresponding CSPICE header from
-Abstract section.
Added arguments' type and size information in the -I/O section.
-Icy Version 1.1.1, 05-FEB-2008 (EDW)
Edited -I/O section, replaced comment
"returns with the same order"
with
"returns with the same measure of vectorization"
-Icy Version 1.1.0, 12-SEP-2004 (EDW)
Added capability to process vectors 'radius',
'longitude', and 'latitude' as input,
returning array 'rectan' on output.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
latitudinal to rectangular coordinates
|