vdot_c |
Table of contents
Procedurevdot_c ( Vector dot product, 3 dimensions ) SpiceDouble vdot_c ( ConstSpiceDouble v1[3], ConstSpiceDouble v2[3] ) AbstractCompute the dot product of two double precision, 3-dimensional vectors. Required_ReadingNone. KeywordsVECTOR Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- v1 I First vector in the dot product. v2 I Second vector in the dot product. The function returns the value of the dot product of `v1' and `v2'. Detailed_Inputv1, v2 are two arbitrary double precision 3-dimensional vectors. Detailed_OutputThe function returns the value of the dot product (inner product) of `v1' and `v2': < v1, v2 > ParametersNone. ExceptionsError free. FilesNone. Particularsvdot_c calculates the dot product of `v1' and `v2' by a simple application of the definition: 1 .----- \ vdot_c = ) v1[i] * v2[i] / '----- i=0 No error checking is performed to prevent or recover from numeric overflow. 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) Suppose that you have a set of double precision 3-dimensional vectors. Check if they are orthogonal to the Z-axis. Example code begins here. /. Program vdot_ex1 ./ #include <stdio.h> #include "SpiceUsr.h" int main( ) { /. Local parameters. ./ #define SETSIZ 4 /. Local variables. ./ SpiceInt i; /. Define the vector set. ./ SpiceDouble v1 [SETSIZ][3] = { { 1.0, 0.0, 0.0 }, { 0.0, -6.0, 0.0 }, {10.0, 0.0, -1.0 }, { 0.0, 0.0, 1.0 } }; SpiceDouble z [3] = { 0.0, 0.0, 1.0 }; /. Check the orthogonality with respect to `z' of each vector in `v1'. ./ for ( i = 0; i < SETSIZ; i++ ) { printf( "\n" ); printf( "Input vector (V1): %5.1f %5.1f %5.1f\n", v1[i][0], v1[i][1], v1[i][2] ); if ( vdot_c ( v1[i], z ) == 0.0 ) { printf( "V1 and Z are orthogonal.\n" ); } else { printf( "V1 and Z are NOT orthogonal.\n" ); } } return ( 0 ); } When this program was executed on a Mac/Intel/cc/64-bit platform, the output was: Input vector (V1): 1.0 0.0 0.0 V1 and Z are orthogonal. Input vector (V1): 0.0 -6.0 0.0 V1 and Z are orthogonal. Input vector (V1): 10.0 0.0 -1.0 V1 and Z are NOT orthogonal. Input vector (V1): 0.0 0.0 1.0 V1 and Z are NOT orthogonal. Restrictions1) The user is responsible for determining that the vectors `v1' and `v2' are not so large as to cause numeric overflow. In most cases this will not present a problem. 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.0.3, 10-AUG-2021 (JDR) Edited the header to comply with NAIF standard. Added complete code example. Improved -Particulars section. -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, 12-NOV-2006 (EDW) Added -Parameters section header. -CSPICE Version 1.0.0, 16-APR-1999 (EDW) (WMO) (NJB) Index_Entriesdot product 3-dimensional vectors |
Fri Dec 31 18:41:14 2021