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
cspice_vprojg

Table of contents
Abstract
I/O
Parameters
Examples
Particulars
Exceptions
Files
Restrictions
Required_Reading
Literature_References
Author_and_Institution
Version
Index_Entries


Abstract


   CSPICE_VPROJG computes the projection of one vector onto another vector.
   All vectors are of arbitrary dimension.

I/O


   Given:

      a        a double precision vector of arbitrary dimension.

               help, a
                  DOUBLE = Array[N]

               This vector is to be projected onto the vector `b'.

      b        a double precision vector of arbitrary dimension.

               help, b
                  DOUBLE = Array[N]

               This vector is the vector which receives the projection.

   the call:

      cspice_vprojg, a, b, p

   returns:

      p        a double precision vector of arbitrary dimension containing the
               projection of `a' onto `b'.

               help, p
                  DOUBLE = Array[N]

               (`p' is necessarily parallel to `b'.)

Parameters


   None.

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.

   1) Define two sets of vectors and compute the projection of
      each vector of the first set on the corresponding vector of
      the second set.

      Example code begins here.


      PRO vprojg_ex1

         ;;
         ;; Local parameters.
         ;;
         SETSIZ = 4

         ;;
         ;; Define the two vector sets.
         ;;
         seta = [ [6.d0, 6.d0, 6.d0, 0.d0], [6.d0, 6.d0, 6.d0, 0.d0],         $
                  [6.d0, 6.d0, 0.d0, 0.d0], [6.d0, 0.d0, 0.d0, 0.d0] ]

         setb = [ [2.d0, 0.d0, 0.d0, 0.d0], [-3.d0, 0.d0, 0.d0, 0.d0],        $
                  [0.d0, 7.d0, 0.d0, 0.d0], [ 0.d0, 0.d0, 9.d0, 0.d0] ]

         ;;
         ;; Calculate the projection
         ;;
         for i=0, SETSIZ-1L do begin

            cspice_vprojg, seta[*,i], setb[*,i], pvec
            print, format='(A,4F5.1)', 'Vector A  : ', seta[*,i]
            print, format='(A,4F5.1)', 'Vector B  : ', setb[*,i]
            print, format='(A,4F5.1)', 'Projection: ', pvec
            print

         endfor

      END


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


      Vector A  :   6.0  6.0  6.0  0.0
      Vector B  :   2.0  0.0  0.0  0.0
      Projection:   6.0  0.0  0.0  0.0

      Vector A  :   6.0  6.0  6.0  0.0
      Vector B  :  -3.0  0.0  0.0  0.0
      Projection:   6.0 -0.0 -0.0 -0.0

      Vector A  :   6.0  6.0  0.0  0.0
      Vector B  :   0.0  7.0  0.0  0.0
      Projection:   0.0  6.0  0.0  0.0

      Vector A  :   6.0  0.0  0.0  0.0
      Vector B  :   0.0  0.0  9.0  0.0
      Projection:   0.0  0.0  0.0  0.0


Particulars


   The projection of a vector `a' onto a vector `b' is, by definition,
   that component of `a' which is parallel to `b'. To find this
   component it is enough to find the scalar ratio of the length of
   `b' to the projection of `a' onto `b', and then use this number to
   scale the length of `b'. This ratio is given by

       ratio = < a, b > / < b, b >

   where <,> denotes the general vector dot product. This routine
   does not attempt to divide by zero in the event that `b' is the
   zero vector.

Exceptions


   1)  If any of the input arguments, `a' or `b', is undefined, an
       error is signaled by the IDL error handling system.

   2)  If any of the input arguments, `a' or `b', 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 vector arguments `a' and `b' do not have the same
       dimension (N), an error is signaled by the Icy interface.

   4)  If the output argument `p' is not a named variable, an error
       is signaled by the Icy interface.

Files


   None.

Restrictions


   1)  No error detection or recovery schemes are incorporated into
       this routine except to insure that no attempt is made to
       divide by zero. Thus, the user is required to make sure that
       the vectors `a' and `b' are such that no floating point overflow
       will occur when the dot products are calculated.

Required_Reading


   ICY.REQ

Literature_References


   [1]  G. Thomas and R. Finney, "Calculus and Analytic Geometry,"
        7th Edition, Addison Wesley, 1988.

Author_and_Institution


   J. Diaz del Rio     (ODC Space)

Version


   -Icy Version 1.0.0, 01-NOV-2021 (JDR)

Index_Entries


   n-dimensional vector projection



Fri Dec 31 18:43:09 2021