CSPICE_DVHAT calculates the unit vector corresponding to a state or states
and the derivative of the unit vector.
Given:
s1 the array(s) defining a state or states;
s1 = (r1, dr1 ).

dt
[6,n] = size(s1); double = class(s1)
the call:
dvhat = cspice_dvhat(s1)
returns:
dvhat the array(s) containing the unit
vector(s) pointing in the direction of the position component(s)
of 's1' and the derivative of the unit vector with respect
to time;
dvhat = [u, du ] where u = r1
 
dt r1
[6,n] = size(dvhat); double = class(dvhat)
'dvhat' returns with the same vectorization measure (N)
as '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.
%
cspice_furnsh( 'standard.tm' )
%
% Define an arbitrary epoch, convert the epoch to ephemeris time.
%
EPOCH = 'Jan 1 2009';
et = cspice_str2et( EPOCH );
%
% Calculate the state of the moon with respect to the earthmoon
% barycenter in J2000, corrected for light time and stellar aberration
% at 'et'.
%
target = 'MOON';
frame = 'J2000';
abcorr = 'LT+S';
observer = 'EARTH BARYCENTER';
[ state, ltime ] = cspice_spkezr( target, et, frame, abcorr, observer );
%
% Calculate the unit vector of 'state' and the derivative of the
% unit vector.
%
ustate = cspice_dvhat( state )
%
% 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
% 
% r
%
% omega = v for r = 1
%
omega = cspice_vnorm( ustate(4:6) );
fprintf( 'Instantaneous angular velocity %2.10e rad/sec.\n', omega )
%
% It's always good form to unload kernels after use,
% particularly in Matlab due to data persistence.
%
cspice_kclear
MATLAB outputs:
Instantaneous angular velocity 2.4810665797e06 rad/sec.
None.
For important details concerning this module's function, please refer to
the CSPICE routine dvhat_c.
MICE.REQ
Mice Version 1.0.1, 03NOV2014, EDW (JPL)
Edited I/O section to conform to NAIF standard for Mice documentation.
Mice Version 1.0.0, 04MAY2010, EDW (JPL)
state of a unit vector parallel to a state vector
