Пример #1
0
   void mtxv_c ( ConstSpiceDouble     m1  [3][3],
                 ConstSpiceDouble     vin [3],
                 SpiceDouble          vout[3]   )

/*

-Brief_I/O

   VARIABLE  I/O              DESCRIPTION
   --------  ---  --------------------------------------------------
   m1         I   3x3 double precision matrix.
   vin        I   3-dimensional double precision vector.
   vout       O   3-dimensional double precision vector. vout is
                  the product m1**t * vin.

-Detailed_Input

   m1         is an arbitrary 3x3 double precision matrix.
              typically, m1 will be a rotation matrix since
              then its transpose is its inverse (but this is NOT
              a requirement).

   vin        is an arbitrary 3-dimensional double precision
              vector.

-Detailed_Output

   vout       is a 3-dimensional double precision vector. vout is
              the product vout = (m1**t)  x (vin). vout can
              overwrite vin.

-Parameters

   None.

-Particulars

   The intermediate results of the operation performed by this routine
   are buffered in a temporary vector which is later moved to the output
   vector.  Thus vout can be actually vin if desired without
   interfering with the computation.

-Examples

   Typically the matrix m1 will be a rotation matrix.  Because
   the transpose of an orthogonal matrix is equivalent to its
   inverse, applying the rotation to the vector is accomplished by
   multiplying the vector by the transpose of the matrix.

          -1
   let  m1   * vin = vout. If m1 is an orthogonal matrix,
   then  (m1**t) * vin = vout.


      If m1 = |  1.  1.  0. |   and  vin = |  5. |
              |             |              |     |
              | -1.  1.  0. |              | 10. |
              |             |              |     |
              |  0.  0.  1. |              | 15. |


   then the call

      mtxv_c ( m1, vin, vout )

   produces the vector


      vout = | -5. |
             |     |
             | 15. |
             |     |
             | 15. |


-Restrictions

   The user is responsible for checking the magnitudes of the
   elements of m1 and vin so that a floating point overflow does
   not occur.

-Exceptions

   Error free.

-Files

   None.

-Author_and_Institution

   E.D. Wright     (JPL)
   W.M. Owen       (JPL)

-Literature_References

   None.

-Version

   -CSPICE Version 1.0.1, 10-NOV-2006   (EDW)

      Added Parameters section header. 

   -CSPICE Version 1.0.0, 16-APR-1999 (EDW)

-Index_Entries

   matrix_transpose times 3-dimensional vector

-&
*/


{ /* Begin mtxv_c */


   /*
   Local variables
   */

   SpiceInt                 i;
   SpiceDouble              vtemp[3];


   for ( i = 0; i <= 2; i++ )
      {
      vtemp[i] = m1[0][i]*vin[0] + m1[1][i]*vin[1] + m1[2][i]*vin[2];
      }


   /* Move the computed result to the output array. */

   MOVED ( vtemp, 3, vout );


} /* End mtxv_c */
Пример #2
0
   void xpose6_c ( ConstSpiceDouble m1[6][6],  SpiceDouble mout[6][6] )

/*

-Brief_I/O

   VARIABLE  I/O  DESCRIPTION
   --------  ---  --------------------------------------------------
    m1        I   6x6 matrix to be transposed.
    mout      O   Transpose of m1.  mout can overwrite m1.
 
-Detailed_Input

    m1            This variable may contain any double precision 6x6
                  matrix.
 
-Detailed_Output

    mout          This variable is a double precision, 6x6 matrix which
                  contains the transpose of m1.  mout may overwrite m1.

-Parameters

   None.

-Exceptions

   Error free.

-Files

   None.

-Particulars

   This is a utility routine intended to facilitate passing state
   transformation matrices between C and Fortan.

-Examples

   Given below is one example of a matrix m1 with the output matrix
   mout which is implied by m1.

           | 1  2  3  4  5  6  |                | 1  0  0  0  0  0 |
           | 0  7  8  9  10 11 |                | 2  7  0  0  0  0 |
           | 0  0  12 13 14 15 |                | 3  8  12 0  0  0 |
      m1=  | 0  0  0  16 17 18 |   then  mout = | 4  9  13 16 0  0 |
           | 0  0  0  0  19 20 |                | 5  10 14 17 19 0 |
           | 0  0  0  0  0  21 |                | 6  11 15 18 20 21|

-Restrictions

   None.

-Literature_References

   None.

-Author_and_Institution

   N.J. Bachman       (JPL)
   W.L. Taber         (JPL)
   W.M. Owen          (JPL)

-Version

   -CSPICE Version 1.0.3, 08-JAN-2014 (BVS)

      Corrected a minor typo in the header.

   -CSPICE Version 1.0.2, 16-JAN-2008   (EDW)

      Corrected typos in header titles:
      
      Detailed Input to Detailed_Input
      Detailed Output to Detailed_Output

   -CSPICE Version 1.0.1, 10-NOV-2006   (EDW)

      Added Keywords and Parameters section headers. 
      Reordered section headers.

   -CSPICE Version 1.0.0, 16-APR-1999 (NJB)

-Index_Entries

      transpose a 6x6_matrix

-&
*/

{  /* Begin xpose6_c */


   /*
   Local constants
   */
   #define   SIZE          6                   
   #define   SIZESQ        36                   

   /*
   Local variables
   */
   SpiceInt                col;
   SpiceInt                row;

   SpiceDouble             temp[SIZE][SIZE];
   

   /*
   Capture a temporary copy of the input matrix.
   */
   MOVED ( m1, SIZESQ, temp );

   /*
   Move the temporary matrix to the output matrix, transposing as
   we go.
   */
   for ( row = 0;  row < SIZE;  row++ )
   {
      for ( col = 0;  col < SIZE;  col++ )
      {
         mout[row][col] = temp[col][row];
      }
   }

} /* End xpose6_c */
Пример #3
0
   void pl2nvc_c ( ConstSpicePlane   * plane,
                   SpiceDouble         normal[3],
                   SpiceDouble       * constant  ) 
/*

-Brief_I/O
 
   Variable  I/O  Description 
   --------  ---  -------------------------------------------------- 
   plane      I   A CSPICE plane. 
   normal, 
   constant   O   A normal vector and constant defining the 
                  geometric plane represented by plane. 
 
-Detailed_Input
 
   plane          is a CSPICE plane. 
 
-Detailed_Output
 
   normal, 
   constant       are, respectively, a unit normal vector and 
                  constant that define the geometric plane 
                  represented by plane.  Let the symbol < a, b > 
                  indicate the inner product of vectors a and b; 
                  then the geometric plane is the set of vectors x 
                  in three-dimensional space that satisfy 
 
                     < x,  normal >  =  constant. 
 
                  normal is a unit vector.  constant is the distance of 
                  the plane from the origin; 
 
                     constant * normal 
 
                  is the closest point in the plane to the origin. 
 
-Parameters
 
   None. 
 
-Exceptions
 
   Error free. 
 
   1)  The input plane MUST have been created by one of the CSPICE 
       routines 
 
          nvc2pl_c ( Normal vector and constant to plane ) 
          nvp2pl_c ( Normal vector and point to plane    ) 
          psv2pl_c ( Point and spanning vectors to plane ) 
 
       Otherwise, the results of this routine are unpredictable. 
 
-Files
 
   None. 
 
-Particulars
 
   CSPICE geometry routines that deal with planes use the `plane' 
   data type to represent input and output planes.  This data type 
   makes the subroutine interfaces simpler and more uniform. 
 
   The CSPICE routines that produce CSPICE planes from data that 
   define a plane are: 
 
      nvc2pl_c ( Normal vector and constant to plane ) 
      nvp2pl_c ( Normal vector and point to plane    ) 
      psv2pl_c ( Point and spanning vectors to plane ) 
 
   The CSPICE routines that convert CSPICE planes to data that 
   define a plane are: 
 
      pl2nvc_c ( Plane to normal vector and constant ) 
      pl2nvp_c ( Plane to normal vector and point    ) 
      pl2psv_c ( Plane to point and spanning vectors ) 
 
-Examples
 
   1)  Given a point in a plane and a normal vector, find the distance 
       of the plane from the origin.  We make a `plane' from the point
       and normal, then convert the plane to a unit normal and constant.
       The constant is the distance of the plane from the origin. 
 
          nvp2pl_c ( normal, point,  &plane    ); 
          pl2nvc_c ( &plane, normal, &constant ); 
 
 
   2)  Apply a linear transformation represented by the matrix m to 
       a plane represented by the normal vector n and the constant c. 
       Find a normal vector and constant for the transformed plane. 

          /. 
          Make a CSPICE plane from n and c, and then find a 
          point in the plane and spanning vectors for the 
          plane.  n need not be a unit vector. 
          ./ 
          nvc2pl_c ( n,       c,     &plane         ); 
          pl2psv_c ( &plane,  point,  span1,  span2 );
           
 
          /.
          Apply the linear transformation to the point and 
          spanning vectors.  All we need to do is multiply 
          these vectors by m, since for any linear 
          transformation T, 
           
                T ( point  +  t1 * span1     +  t2 * span2 ) 
      
             =  T (point)  +  t1 * T(span1)  +  t2 * T(span2), 
            
          which means that T(point), T(span1), and T(span2) 
          are a point and spanning vectors for the transformed 
          plane. 
          ./
      
          mxv_c ( m, point, tpoint ); 
          mxv_c ( m, span1, tspan1 ); 
          mxv_c ( m, span2, tspan2 ); 
 
          /.
          Make a new CSPICE plane tplane from the 
          transformed point and spanning vectors, and find a 
          unit normal and constant for this new plane. 
          ./
          
          psv2pl_c ( tpoint,   tspan1,  tspan2,   &tplane ); 
          pl2nvc_c ( &tplane,  tn,      &tc               ); 
          

 
-Restrictions
 
   None. 
 
-Literature_References
 
   [1] `Calculus and Analytic Geometry', Thomas and Finney. 
 
-Author_and_Institution
 
   N.J. Bachman   (JPL) 
 
-Version
 
   -CSPICE Version 1.0.1, 06-FEB-2003 (EDW)

       Trivial correction to header docs.

   -CSPICE Version 1.0.0, 05-MAR-1999 (NJB)

-Index_Entries
 
   plane to normal vector and constant 
 
-&
*/

{ /* Begin pl2nvc_c */

   
   /*
   Unpack the plane.
   */

   MOVED ( plane->normal, 3, normal );
   
   *constant = plane->constant;


} /* End pl2nvc_c */
Пример #4
0
   void vcrss_c ( ConstSpiceDouble   v1[3],
                  ConstSpiceDouble   v2[3],
                  SpiceDouble        vout[3] )
/*

-Brief_I/O

   VARIABLE  I/O  DESCRIPTION
   --------  ---  --------------------------------------------------
   v1         I     Left hand vector for cross product.
   v2         I     Right hand vector for cross product.
   vout       O     Cross product v1xv2.
                    vout can overwrite either v1 or v2.

-Detailed_Input

   v1      This may be any 3-dimensional vector.  Typically, this
           might represent the (possibly unit) vector to a planet,
           sun, or a star which defines the orientation of axes of
           some coordinate system.

   v2      Ditto.

-Detailed_Output

   vout    This variable represents the cross product of v1 and v2.
           vout may overwrite v1 or v2.

-Parameters

   None.

-Particulars

   vcrss_c calculates the three dimensional cross product of two
   vectors according to the definition.  The cross product is stored
   in a buffer vector until the calculation is complete.  Thus vout
   may overwrite v1 or v2 without interfering with intermediate
   computations.

   If v1 and v2 are large in magnitude (taken together, their
   magnitude surpasses the limit allow by the computer) then it may
   be possible to generate a floating point overflow from an
   intermediate computation even though the actual cross product
   may be well within the range of double precision numbers.
   vcrss_c does NOT check the magnitude of v1 or v2 to insure that
   overflow will not occur.

-Examples

   v1                  v2                  vout (=v1Xv2)
   -----------------------------------------------------------------
   (0, 1, 0)           (1, 0, 0)           (0, 0, -1)
   (5, 5, 5)           (-1, -1, -1)        (0, 0, 0)

-Restrictions

   No checking of v1 or v2 is done to prevent floating point
   overflow. The user is required to determine that the magnitude
   of each component of the vectors is within an appropriate range
   so as not to cause floating point overflow. In almost every case
   there will be no problem and no checking actually needs to be
   done.

-Exceptions

   Error free.

-Files

   None.

-Author_and_Institution

   W.M. Owen       (JPL)
   E.D. Wright     (JPL)

-Literature_References

   None.

-Version

   -CSPICE Version 1.1.0, 22-OCT-1998 (NJB)

      Made input vectors const.

   -CSPICE Version 1.0.1, 06-MAR-1998 (EDW)
   
      Minor header correction.  Added use of MOVED.

   -CSPICE Version 1.0.0, 08-FEB-1998 (EDW)

-Index_Entries

   vector cross product

-&
*/

{ /* Begin vcrss_c */

   /*
   Local variables
   */

   SpiceDouble  vtemp[3];


   /*
   Calculate the cross product of v1 and v2, store in vtemp.
   */

   vtemp[0] = v1[1]*v2[2] - v1[2]*v2[1];
   vtemp[1] = v1[2]*v2[0] - v1[0]*v2[2];
   vtemp[2] = v1[0]*v2[1] - v1[1]*v2[0];


   /*
   Now move the result into vout.
   */

   MOVED ( vtemp, 3, vout );


} /* End vcrss_c */
Пример #5
0
   void el2cgv_c ( ConstSpiceEllipse   * ellipse,
                   SpiceDouble           center[3],
                   SpiceDouble           smajor[3],
                   SpiceDouble           sminor[3]  ) 

/*

-Brief_I/O
 
   Variable  I/O  Description 
   --------  ---  -------------------------------------------------- 
   ellipse    I   A CSPICE ellipse. 
   center, 
   smajor, 
   sminor     O   Center and semi-axes of ellipse. 
 
-Detailed_Input
 
   ellipse        is a CSPICE ellipse. 
 
-Detailed_Output
 
   center, 
   smajor, 
   sminor         are, respectively, a center vector, a semi-major 
                  axis vector, and a semi-minor axis vector that 
                  generate the input ellipse.  This ellipse is the 
                  set of points 
 
                     center + cos(theta) smajor + sin(theta) sminor 
 
                  where theta ranges over the interval (-pi, pi]. 
 
-Parameters
 
   None. 
 
-Exceptions
 
   Error free. 
 
-Files
 
   None. 
 
-Particulars
 
   CSPICE ellipses serve to simplify calling sequences and reduce 
   the chance for error in declaring and describing argument lists 
   involving ellipses. 
 
   The set of ellipse conversion routines is 
 
      cgv2el_c ( Center and generating vectors to ellipse ) 
      el2cgv_c ( Ellipse to center and generating vectors ) 
 
   A word about the output of this routine:   the semi-major axis of 
   an ellipse is a vector of largest possible magnitude in the set 
 
      cos(theta) vec1  +  sin(theta) vec2, 
 
   where theta is in the interval (-pi, pi].  There are two such 
   vectors; they are additive inverses of each other. The semi-minor 
   axis is an analogous vector of smallest possible magnitude.  The 
   semi-major and semi-minor axes are orthogonal to each other.  If 
   smajor and sminor are choices of semi-major and semi-minor axes, 
   then the input ellipse can also be represented as the set of 
   points 
 
 
      center + cos(theta) smajor + sin(theta) sminor 
 
   where theta ranges over the interval (-pi, pi]. 
 
 
-Examples
 
   1)  Find the semi-axes of the limb of an ellipsoid. 
 
          #include "SpiceUsr.h"
                  .
                  .
                  .
          /.
          Our viewing location is viewpt.  The radii of the 
          ellipsoid are a, b, and c. 
          ./
          edlimb_c ( a, b, c, viewpt, &limb );

          el2cgv_c ( &limb, center, smajor, sminor ); 
 
-Restrictions
 
   None. 
 
-Literature_References
 
   None. 
 
-Author_and_Institution
 
   N.J. Bachman   (JPL) 
 
-Version
 
   -CSPICE Version 1.0.0, 12-JUN-1999 (NJB)

-Index_Entries
 
   ellipse to center and generating vectors 
 
-&
*/

{ /* Begin el2cgv_c */

   /*
   Error free.
   */


   MOVED ( ellipse->center,    3, center );
   MOVED ( ellipse->semiMajor, 3, smajor );
   MOVED ( ellipse->semiMinor, 3, sminor );
   

} /* End el2cgv_c */
Пример #6
0
   void mxmg_c ( const void    * m1,
                 const void    * m2,
                 SpiceInt        nrow1,
                 SpiceInt        ncol1,
                 SpiceInt        ncol2,
                 void          * mout   )
/*

-Brief_I/O

   VARIABLE  I/O  DESCRIPTION
   --------  ---  --------------------------------------------------
   m1         I   nrow1 X ncol1 double precision matrix.
   m2         I   ncol1 X ncol2 double precision matrix.
   nrow1      I   Row dimension of m1 (and also mout).
   ncol1      I   Column dimension of m1 and row dimension of m2.
   ncol2      I   Column dimension of m2 (and also mout).
   mout       O   nrow1 X ncol2 double precision matrix.

-Detailed_Input

   m1         is any double precision matrix of arbitrary size.

   m2         is any double precision matrix of arbitrary size.
              The number of rows in m2 must match the number of
              columns in m1.

   nrow1      is the number of rows in both m1 and mout.

   ncol1      is the number of columns in m1 and (by necessity)
              the number of rows of m2.

   ncol2      is the number of columns in both m2 and mout.

-Detailed_Output

   mout
              mout is the product matrix defined by

                 mout = (m1) x (m2)

              mout is a double precision matrix of dimension nrow1 x
              ncol2.

              mout may overwrite m1 or m2.  Note that this capability
              does not exist in the Fortran version of SPICELIB; in the
              Fortran version, the output must not overwrite either
              input.
-Parameters

   None.

-Exceptions

   1) If dynamic allocation of memory fails, the error
      SPICE(MEMALLOCFAILED) is signalled.

-Files

   None.

-Particulars

   The code reflects precisely the following mathematical expression

   For each value of the subscript i from 1 to nrow1, and j from 1
   to ncol2:

      mout(i,j) = Summation from k=1 to ncol1 of  m1(i,k) * m2(k,j)


-Examples


   Let

      m1 = | 1.0  4.0 |    and  m2 =  | 1.0  3.0  5.0 |
           |          |                               |
           | 2.0  5.0 |               | 2.0  4.0  6.0 |
           |          |
           | 3.0  6.0 |

   and

      nrow1  = 3
      ncol1  = 2
      ncol2  = 3

   Then the call


      mxmg ( m1, m2, nrow1, ncol1, ncol2, mout );


   produces the matrix

      mout = |  9.0  19.0  29.0 |
             |                  |
             | 12.0  26.0  40.0 |
             |                  |
             | 15.0  33.0  51.0 |


-Restrictions

   1) No error checking is performed to prevent numeric overflow or
      underflow.

   2) No error checking performed to determine if the input and
      output matrices have, in fact, been correctly dimensioned.

-Literature_References

   None.

-Author_and_Institution

   N.J. Bachman       (JPL)
   W.M. Owen          (JPL)

-Version

   -CSPICE Version 1.1.2, 16-JAN-2008   (EDW)

      Corrected typos in header titles:
      
      Detailed Input to Detailed_Input
      Detailed Output to Detailed_Output
      
   -CSPICE Version 1.1.1, 10-NOV-2006   (EDW)

      Added Parameters section header. 

   -CSPICE Version 1.1.0, 28-AUG-2001 (NJB)

      Const-qualified input arrays.

   -CSPICE Version 1.0.0, 16-APR-1999 (NJB)

-Index_Entries

   matrix times matrix n-dimensional_case

-&
*/

{  /* Begin mxmg_c */


   /*
   Local macros

   We'd like to be able to refer to the elements of the input and output
   matrices using normal subscripts, for example, m1[2][3].  Since the
   compiler doesn't know how to compute index offsets for the array
   arguments, which have user-adjustable size, we must compute the
   offsets ourselves.  To make syntax a little easier to read (we hope),
   we'll use macros to do the computations.

   The macro INDEX(width, i,j) computes the index offset from the array
   base of the element at position [i][j] in a 2-dimensional matrix
   having the number of columns indicated by width.  For example, if
   the input matrix m1 has 2 rows and 3 columns, the element at position
   [0][1] would be indicated by

      m1[ INDEX(3,0,1) ]

   */

   #define INDEX( width, row, col )     ( (row)*(width) + (col) )


   /*
   Local variables
   */
   SpiceDouble             innerProduct;
   SpiceDouble            *tmpmat;
   SpiceDouble            *loc_m1;
   SpiceDouble            *loc_m2;

   SpiceInt                col;
   SpiceInt                nelts;
   SpiceInt                row;
   SpiceInt                i;

   size_t                  size;


   /*
   Allocate space for a temporary copy of the output matrix, which
   has nrow1 rows and ncol2 columns.
   */
   nelts   =  nrow1 * ncol2;
   size    =  (size_t) ( nelts * sizeof(SpiceDouble) );

   tmpmat  =  (SpiceDouble *) malloc ( size );

   if ( tmpmat == (SpiceDouble *)0 )
   {
      chkin_c  ( "mxmg_c"                                          );
      setmsg_c ( "An attempt to create a temporary matrix failed." );
      sigerr_c ( "SPICE(MEMALLOCFAILED)"                           );
      chkout_c ( "mxmg_c"                                          );
      return;
   }

   /*
   Cast the input pointers to pointers to SpiceDoubles.  Note:  the
   original variables are pointers to void so that callers may
   supply the array names as arguments without casting them to
   SpiceDoubles.  The naked array name is considered by the compiler
   to be an incompatible pointer type with (SpiceDouble *), so we
   can't simply declare the arguments to be (SpiceDouble *).  On the
   other hand, every pointer type can be cast to (void *).
   */

   loc_m1 = (SpiceDouble *) m1;
   loc_m2 = (SpiceDouble *) m2;


   /*
   Compute the product.  The matrix element at position (row,col) is
   the inner product of the row of m1 having index row and the
   column of m2 having index col.  We compute index offsets using
   the macro INDEX.
   */

   for ( row = 0;  row < nrow1;  row++ )
   {

      for ( col = 0;  col < ncol2;  col++ )
      {
         innerProduct = 0.0;

         for ( i = 0;  i < ncol1;  i++ )
         {
            innerProduct  +=    loc_m1[ INDEX(ncol1,  row, i  ) ]
                              * loc_m2[ INDEX(ncol2,  i,   col) ];
         }

         tmpmat [ INDEX( ncol2, row, col ) ]  =  innerProduct;
      }
   }

   /*
   Move the result from tmpmat into mout.
   */
   MOVED ( tmpmat, nelts, mout );

   /*
   Free the temporary matrix.
   */
   free ( tmpmat );


} /* End mxmg_c */
Пример #7
0
   void cgv2el_c ( ConstSpiceDouble    center[3],
                   ConstSpiceDouble    vec1  [3],
                   ConstSpiceDouble    vec2  [3],
                   SpiceEllipse      * ellipse   ) 

/*

-Brief_I/O
 
   Variable  I/O  Description 
   --------  ---  -------------------------------------------------- 
   center, 
   vec1, 
   vec2       I   Center and two generating vectors for an ellipse. 
   ellipse    O   The CSPICE ellipse defined by the input vectors. 
 
-Detailed_Input
 
   center, 
   vec1, 
   vec2           are a center and two generating vectors defining 
                  an ellipse in three-dimensional space.  The 
                  ellipse is the set of points 
 
                     center  +  cos(theta) vec1  +  sin(theta) vec2 
 
                  where theta ranges over the interval (-pi, pi]. 
                  vec1 and vec2 need not be linearly independent. 
 
-Detailed_Output
 
   ellipse        is the CSPICE ellipse defined by the input 
                  vectors. 
 
-Parameters
 
   None. 
 
-Exceptions
 
   1)  If vec1 and vec2 are linearly dependent, ellips will be 
       degenerate.  CSPICE ellipses are allowed to represent 
       degenerate geometric ellipses. 
 
-Files
 
   None. 
 
-Particulars
 
   CSPICE ellipses serve to simplify calling sequences and reduce 
   the chance for error in declaring and describing argument lists 
   involving ellipses. 
 
   The set of ellipse conversion routines is 
 
      cgv2el_c ( Center and generating vectors to ellipse ) 
      el2cgv_c ( Ellipse to center and generating vectors ) 
 
-Examples
 
   1)  Find the intersecton of an ellipse with a plane.  The ellipse 
       is defined by the vectors center, vec1, and vec2.  The plane 
       is defined by the normal vector n and the constant c. 
 
          #include "SpiceUsr.h"
                    .
                    .
                    .
          /.
          Make a CSPICE ellipse.  Make a plane while we're at it. 
          ./
          cgv2el_c ( center, vec1, vec2,  &ellipse ); 
          nvc2pl_c ( n,      c,           &plane   ); 

          /.
          Find the intersection of the ellipse and plane. 
          nxpts is the number of intersection points; xpt1 
          and xpt2 are the points themselves. 
          ./
          inelpl_c ( &ellipse, &plane, &nxpts, xpt1, xpt2 );
 
 
-Restrictions
 
   None. 
 
-Literature_References
 
   None. 
 
-Author_and_Institution
 
   N.J. Bachman   (JPL) 
 
-Version
 
   -CSPICE Version 1.0.0, 05-MAR-1999 (NJB)

-Index_Entries
 
   center and generating vectors to ellipse 
 
-&
*/

{ /* Begin cgv2el_c */


   /*
   Participate in error tracing.
   */
   chkin_c ( "cgv2el_c" );

   /*
   The center of the ellipse is held in the first three elements.
   */
   MOVED ( center, 3, ellipse->center );

   /*
   Find the semi-axes of the ellipse.  These may be degenerate.
   */
   saelgv_c ( vec1, vec2, ellipse->semiMajor, ellipse->semiMinor );
   
   
   chkout_c ( "cgv2el_c" );

} /* End cgv2el_c */
Пример #8
0
   void mtxm_c ( ConstSpiceDouble    m1  [3][3],
                 ConstSpiceDouble    m2  [3][3],
                 SpiceDouble         mout[3][3] )

/*

-Brief_I/O

   VARIABLE  I/O  DESCRIPTION
   --------  ---  --------------------------------------------------
   m1         I   3x3 double precision matrix.
   m2         I   3x3 double precision matrix.
   mout       O   The produce m1 transpose times m2.

-Detailed_Input

   m1         is any 3x3 double precision matrix. Typically,
              m1 will be a rotation matrix since then its
              transpose is its inverse (but this is not a
              requirement).

   m2         is any 3x3 double precision matrix.

-Detailed_Output

   mout       is a 3x3 double precision matrix. mout is the
              product

                          t
                 mout = m1  m2

              mout may overwrite either m1 or m2.

-Parameters

   None.

-Particulars

   The code reflects precisely the following mathematical expression

   For each value of the subscripts i and j from 0 to 2:

                     2
                    __
                    \
      mout[i][j] =  /_  m1[k][i] * m2[k][j]
                    k=0

   Note that the reversal of the k and i subscripts in the left-hand
   matrix m1 is what makes mout the product of the TRANSPOSE of M1
   and not simply of m1 itself.  Also, the intermediate results of
   the operation above are buffered in a temporary matrix which is
   later moved to the output matrix.  Thus mout can be actually be
   m1 or m2 if desired without interfering with the computations.

-Examples

   Let m1 = | 1.  2.  3. |
            |            |
            | 4.  5.  6. |
            |            |
            | 7.  8.  9. |


       m2 = |  1.   1.  0. |
            |              |
            | -1.   1.  0. |
            |              |
            |  0.   0.  1. |

   then the call

   mtxm_c ( m1, m2, mout );

   produces the matrix

   mout = | -3.   5.  7. |
          |              |
          | -3.   7.  8. |
          |              |
          | -3.   9.  9. |


-Restrictions

   The user is responsible for checking the magnitudes of the
   elements of m1 and m2 so that a floating point overflow does
   not occur.  (In the typical use where m1 and m2 are rotation
   matrices, this not a risk at all.)

-Exceptions

   Error free.

-Files

   None

-Author_and_Institution

   W.M. Owen       (JPL)
   E.D  Wright     (JPL)

-Literature_References

   None.

-Version

   -CSPICE Version 1.0.0, 16-APR-1999 (EDW)

-Index_Entries

   matrix_transpose times matrix 3x3_case

-&
*/


{ /* Begin mtxm_c */

   /*
   Local variables
   */

   SpiceInt                i;
   SpiceInt                j;

   SpiceDouble             mtemp[3][3];


   for ( i = 0; i < 3;  i++ )
      {

      for ( j = 0; j < 3;  j++ )
         {
         mtemp[i][j]  =     m1[0][i] * m2[0][j]
                         +  m1[1][i] * m2[1][j]
                         +  m1[2][i] * m2[2][j];
         }
      }

   /*
   Copy the results from the temporary matrix to the return matrix.
   */

   MOVED ( mtemp, 9, mout );


} /* End mtxm_c */
Пример #9
0
   void vequg_c ( ConstSpiceDouble  * vin,
                  SpiceInt            ndim,
                  SpiceDouble       * vout )
/*

-Brief_I/O

   VARIABLE  I/O  DESCRIPTION
   --------  ---  --------------------------------------------------
    vin       I   ndim-dimensional double precision vector.
    ndim      I   Dimension of vin (and also vout).
    vout      O   ndim-dimensional double precision vector set
                  equal to vin.

-Detailed_Input

   vin      is a double precision vector of arbitrary dimension.

   ndim     is the number of components of vin.

-Detailed_Output

   vout     is a double precision vector set equal to vin.

-Parameters

   None.

-Particulars

   The code simply sets each component of vout equal to the
   corresponding component of vin.

-Examples

   Let state be a state vector. Set abstat equal to state.

   vequg_c  ( state, 6, abstate );

   Note that this routine may be used in place of MOVED, which
   sets each output array element equal to the corresponding
   input array element.

-Restrictions

   None.

-Exceptions

   1)  If ndim is not physically realistic, greater than zero, a
       BADDIMENSION error is flagged.

-Files

   None.

-Author_and_Institution

   W.M. Owen       (JPL)
   E.D. Wright     (JPL)

-Literature_References

   None.

-Version

   -CSPICE Version 1.0.0, 23-AUG-1999   (EDW) (NJB)

-Index_Entries

   assign an n-dimensional vector to another

-&
*/

{ /* Begin vequg_c */


   /*
   Use discovery check-in.
   */


   /* Check ndim is cool.  Dimension is positive definite. */

   if ( ndim <= 0 )
      {

      chkin_c    ( "vequg_c"                                      );
      SpiceError ( "Vector dimension less than or equal to zero",
                   "BADDIMENSION"                                 );
      chkout_c   ( "vequg_c"                                     );
      return;

      }


   /* Do the equality thing. */

   MOVED ( vin, ndim, vout );


} /* End vequg_c */