CSPICE_DVHAT calculates the unit vector corresponding to a state and
the time derivative of the unit vector.
For important details concerning this module's function, please refer to
the CSPICE routine dvhat_c.
s1 a double precision 6-vector defining a state;
s1 = (r1, dr1 ).
cspice_dvhat, s1, sout
sout a double precision 6-vector containing the unit vector pointing
in the direction of position component of 's1' and the derivative
of the unit vector with respect to time;
sout = [u, du ] where u = r1
'sout' may overwrite 's1'.
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.
Suppose that 'state' gives the apparent state of a body with
respect to an observer. This routine can be used to compute the
instantaneous angular rate of the object across the sky as seen
from the observers vantage.
;; Load SPK, PCK, and LSK kernels, use a meta kernel for convenience.
;; Define an arbitrary epoch, convert the epoch to ephemeris time.
EPOCH = 'Jan 1 2009'
cspice_str2et, EPOCH, et
;; Calculate the state of the moon with respect to the earth-moon
;; barycenter in J2000, corrected for light time and stellar aberration
;; at 'et'.
target = 'MOON'
frame = 'J2000'
abcorr = 'LT+S'
observer = 'EARTH BARYCENTER'
cspice_spkezr, target, et, frame, abcorr, observer, state, ltime
;; Calculate the unit vector of 'state' and the derivative of the
;; unit vector.
cspice_dvhat, state, ustate
;; Calculate the instantaneous angular velocity from the magnitude of the
;; derivative of the unit vector.
;; v = r x omega
;; ||omega|| = ||v|| for r . v = 0
;; ||omega|| = ||v|| for ||r|| = 1
omega = cspice_vnorm( ustate[3:5] )
print, 'Instantaneous angular velocity, rad/sec', omega
;; It's always good form to unload kernels after use,
;; particularly in IDL due to data persistence.
Instantaneous angular velocity, rad/sec 2.4810666e-06
-Icy Version 1.0.1, 09-MAY-2016, EDW (JPL)
Eliminated typo in example code; no change to functionality.
-Icy Version 1.0.4, 04-MAY-2010, EDW (JPL)
Added complete example code.
-Icy Version 1.0.3, 03-DEC-2009, EDW (JPL)
Edited header, improved/clarified I/O descriptions.
-Icy Version 1.0.2, 09-DEC-2005, EDW (JPL)
Added Examples section.
-Icy Version 1.0.1, 10-OCT-2005, EDW (JPL)
Corrected notation |r| to ||r||; edited header.
-Icy Version 1.0.0, 16-JUN-2003, EDW (JPL)
State of a unit vector parallel to a state vector