| ucrss_c |
|
Table of contents
Procedure
ucrss_c ( Unitized cross product, 3x3 )
void ucrss_c ( ConstSpiceDouble v1[3],
ConstSpiceDouble v2[3],
SpiceDouble vout[3] )
AbstractCompute the normalized cross product of two 3-vectors. Required_ReadingNone. KeywordsVECTOR Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- v1 I Left vector for cross product. v2 I Right vector for cross product. vout O Normalized cross product of `v1' and `v2'. Detailed_Input
v1,
v2 are two double precision 3-dimensional vectors.
Typically, these might represent the (possibly unit)
vector to a planet, Sun, or a star which defines the
orientation of axes of some reference frame.
Detailed_Output
vout is the double precision 3-dimensional normalized cross
product of `v1' and `v2'. `vout' is the result of the
computation
v1 x v2
-----------
|| v1 x v2 ||
where "x" denotes the cross product and ||x||| the norm
of a vector `x'.
ParametersNone. Exceptions
Error free.
1) If the cross product of `v1' and `v2' yields the zero-vector,
then the zero-vector is returned instead of a vector of
unit length.
FilesNone. ParticularsNone. 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) Define two sets of vectors and compute the normalized cross
product of each vector in first set and the corresponding
vector in the second set.
Example code begins here.
/.
Program ucrss_ex1
./
#include <stdio.h>
#include "SpiceUsr.h"
int main( )
{
/.
Local parameters.
./
#define NDIM 3
#define SETSIZ 2
/.
Local variables.
./
SpiceDouble vout [NDIM];
SpiceInt i;
/.
Define the two vector sets.
./
SpiceDouble v1 [SETSIZ][NDIM] = {
{ 0.0, 1.0, 0.0 },
{ 5.0, 5.0, 5.0 } };
SpiceDouble v2 [SETSIZ][NDIM] = {
{ 3.0, 0.0, 0.0 },
{-2.0, -2.0, -2.0 } };
/.
Calculate the cross product of each pair of vectors
./
for ( i = 0; i < SETSIZ; i++ )
{
ucrss_c ( v1[i], v2[i], vout );
printf( "Vector A : %4.1f %4.1f %4.1f\n",
v1[i][0], v1[i][1], v1[i][2] );
printf( "Vector B : %4.1f %4.1f %4.1f\n",
v2[i][0], v2[i][1], v2[i][2] );
printf( "Normalized cross product: %4.1f %4.1f %4.1f\n",
vout[0], vout[1], vout[2] );
printf( "\n" );
}
return ( 0 );
}
When this program was executed on a Mac/Intel/cc/64-bit
platform, the output was:
Vector A : 0.0 1.0 0.0
Vector B : 3.0 0.0 0.0
Normalized cross product: 0.0 0.0 -1.0
Vector A : 5.0 5.0 5.0
Vector B : -2.0 -2.0 -2.0
Normalized cross product: 0.0 0.0 0.0
RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) W.M. Owen (JPL) W.L. Taber (JPL) E.D. Wright (JPL) Version
-CSPICE Version 1.1.1, 22-MAY-2020 (JDR)
Edited the header to comply with NAIF standard. Added complete
code example.
-CSPICE Version 1.1.0, 22-OCT-1998 (NJB)
Made input vectors const.
-CSPICE Version 1.0.0, 08-FEB-1998 (EDW) (WMO) (WLT)
Index_Entriesunitized cross product |
Fri Dec 31 18:41:14 2021