Index of Functions: A B C D E F G H I J K L M N O P Q R S T U V W X
Index Page dvhat_c

Table of contents

Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input | Detailed_Output Parameters Exceptions Files Particulars Examples | Restrictions Literature_References Author_and_Institution Version Index_Entries

#### Procedure

       dvhat_c ( Derivative and unit vector "V-hat" of a state)

       void dvhat_c ( ConstSpiceDouble s1  [6],
                      SpiceDouble      sout[6] )

#### Abstract

       Find the unit vector corresponding to a state vector and the
       derivative of the unit vector.

#### Required_Reading

       None.

#### Keywords

       DERIVATIVE
       MATH
       VECTOR

#### Brief_I/O

       VARIABLE  I/O  DESCRIPTION
       --------  ---  --------------------------------------------------
       s1         I   State to be normalized.
       sout       O   Unit vector s1 / |s1|, and its time derivative.

#### Detailed_Input

       s1          is any double precision state. If the position
                   component of the state is the zero vector, this
                   routine will detect it and will not attempt to divide
                   by zero.

#### Detailed_Output

       sout        is a state 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' may overwrite `s1'.

#### Parameters

       None.

#### Exceptions

       Error free.

       1)  If `s1' represents the zero vector, then the position
           component of `sout' will also be the zero vector. The
           velocity component will be the velocity component
           of `s1'.

#### Files

       None.

#### Particulars

       Let `s1' be a state vector with position and velocity components P
       and V respectively. From these components one can compute the
       unit vector parallel to P, call it `u' and the derivative of `u'
       with respect to time, `du'. This pair (u,du) is the state returned
       by this routine in `sout'.

#### Examples

       The numerical results shown for this example may differ across
       platforms. The results depend on the SPICE kernels used as
       input, the compiler and supporting libraries, and the machine
       specific arithmetic implementation.

       1) 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.

          Use the meta-kernel shown below to load the required SPICE
          kernels.

             KPL/MK

             File name: dvhat_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
                pck00008.tpc                  Planet orientation and
                                              radii
                naif0009.tls                  Leapseconds

             \begindata

                KERNELS_TO_LOAD = ( 'de421.bsp',
                                    'pck00008.tpc',
                                    'naif0009.tls'  )

             \begintext

             End of meta-kernel

          Example code begins here.

          /.
             Program dvhat_ex1
          ./
          #include <stdio.h>
          #include <math.h>
          #include "SpiceUsr.h"

          int main()
          {

             SpiceDouble       et;
             SpiceDouble       lt;
             SpiceDouble       omega;
             SpiceDouble       state  [6];
             SpiceDouble       ustate [6];

             SpiceChar       * epoch  = "Jan 1 2009";
             SpiceChar       * target = "MOON";
             SpiceChar       * frame  = "J2000";
             SpiceChar       * abcorr = "LT+S";
             SpiceChar       * obsrvr = "EARTH BARYCENTER";

             /.
             Load SPK, PCK, and LSK kernels, use a meta kernel for
             convenience.
             ./
             furnsh_c ( "dvhat_ex1.tm" );

             /.
             Define an arbitrary epoch, convert the epoch to ephemeris time.
             ./
             str2et_c ( 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'.
             ./

             spkezr_c ( target, et, frame, abcorr, obsrvr, state, &lt );

             /.
             Calculate the unit vector of `state' and the derivative of the
             unit vector.
             ./
             dvhat_c ( 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
                             -----
                             ||r||

                 ||omega|| = ||v||  for  ||r|| = 1
             ./
             omega = vnorm_c ( ustate+3 );

             printf( "Instantaneous angular velocity (rad/sec): %18.12e\n",
                                                                     omega );

             return ( 0 );
          }

          When this program was executed on a Mac/Intel/cc/64-bit
          platform, the output was:

          Instantaneous angular velocity (rad/sec): 2.481066592694e-06

#### Restrictions

       None.

#### Literature_References

       None.

#### Author_and_Institution

       J. Diaz del Rio     (ODC Space)
       E.D. Wright         (JPL)

#### Version

       -CSPICE Version 1.0.2, 02-JUL-2021 (JDR)

           Edits to header to comply with NAIF standard. Added
           meta-kernel to the example.

       -CSPICE Version 1.0.1, 06-MAY-2010 (EDW)

           Reordered header sections to proper NAIF convention.
           Minor edit to code comments eliminating typo.

       -CSPICE Version 1.0.0, 07-JUL-1999 (EDW)

#### Index_Entries

       State of a unit vector parallel to a state vector

#### Link to routine dvhat_c source file dvhat_c.c

    Fri Dec 31 18:41:05 2021