vcrss_c |
Table of contents
Procedurevcrss_c ( Vector cross product, 3 dimensions ) void vcrss_c ( ConstSpiceDouble v1[3], ConstSpiceDouble v2[3], SpiceDouble vout[3] ) AbstractCompute the cross product of two 3-dimensional vectors. Required_ReadingNone. KeywordsVECTOR Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- v1 I Left hand vector for cross product. v2 I Right hand vector for cross product. vout O Cross product v1 x v2. Detailed_Inputv1, v2 are two 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_Outputvout is the cross product of `v1' and `v2'. `vout' may overwrite `v1' or `v2'. ParametersNone. ExceptionsError free. FilesNone. Particularsvcrss_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 allowed 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. ExamplesThe 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 cross product of each vector in first set and the corresponding vector in the second set. Example code begins here. /. Program vcrss_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 seta [SETSIZ][NDIM] = { {0.0, 1.0, 0.0}, {5.0, 5.0, 5.0} }; SpiceDouble setb [SETSIZ][NDIM] = { { 1.0, 0.0, 0.0}, {-1.0, -1.0, -1.0} }; /. Calculate the cross product of each pair of vectors ./ for ( i = 0; i < SETSIZ; i++ ) { vcrss_c ( seta[i], setb[i], vout ); printf( "Vector A : %4.1f %4.1f %4.1f\n", seta[i][0], seta[i][1], seta[i][2] ); printf( "Vector B : %4.1f %4.1f %4.1f\n", setb[i][0], setb[i][1], setb[i][2] ); printf( "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 : 1.0 0.0 0.0 Cross product: 0.0 0.0 -1.0 Vector A : 5.0 5.0 5.0 Vector B : -1.0 -1.0 -1.0 Cross product: 0.0 0.0 0.0 Restrictions1) 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. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) W.M. Owen (JPL) E.D. Wright (JPL) Version-CSPICE Version 1.1.1, 05-JUL-2021 (JDR) Edited the header to comply with NAIF standard. Added complete code example based on existing example. -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) (WMO) Index_Entriesvector cross product |
Fri Dec 31 18:41:14 2021