1 /* 2 3 -Procedure dvcrss_c ( Derivative of Vector cross product ) 4 5 -Abstract 6 7 Compute the cross product of two 3-dimensional vectors 8 and the derivative of this cross product. 9 10 -Disclaimer 11 12 THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE 13 CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. 14 GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE 15 ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE 16 PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" 17 TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY 18 WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A 19 PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC 20 SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE 21 SOFTWARE AND RELATED MATERIALS, HOWEVER USED. 22 23 IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA 24 BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT 25 LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, 26 INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, 27 REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE 28 REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. 29 30 RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF 31 THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY 32 CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE 33 ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. 34 35 -Required_Reading 36 37 None. 38 39 -Keywords 40 41 VECTOR 42 DERIVATIVE 43 MATH 44 45 */ 46 47 #include "SpiceUsr.h" 48 #include "SpiceZfc.h" 49 #include "SpiceZst.h" 50 #undef dvcrss_c 51 dvcrss_c(ConstSpiceDouble s1[6],ConstSpiceDouble s2[6],SpiceDouble sout[6])52 void dvcrss_c ( ConstSpiceDouble s1 [6], 53 ConstSpiceDouble s2 [6], 54 SpiceDouble sout[6] ) 55 56 /* 57 58 -Brief_I/O 59 60 VARIABLE I/O DESCRIPTION 61 -------- --- -------------------------------------------------- 62 s1 I Left hand state for cross product and derivative. 63 s2 I Right hand state for cross product and derivative. 64 sout O State associated with cross product of positions. 65 66 -Detailed_Input 67 68 s1 This may be any state vector. Typically, this 69 might represent the apparent state of a planet or the 70 Sun, which defines the orientation of axes of 71 some coordinate system. 72 73 s2 A state vector. 74 75 -Detailed_Output 76 77 sout This variable represents the state associated with the 78 cross product of the position components of 's1' and 's2.' 79 In otherwords if s1 = (P1,V1) and s2 = (P2,V2) then 80 'sout' is ( P1xP2, d/dt{ P1xP2 } ) 81 82 'sout' may overwrite 's1' or 's2'. 83 84 -Parameters 85 86 None. 87 88 -Exceptions 89 90 Error free. 91 92 1) If 's1' and 's2' are large in magnitude (taken together, 93 their magnitude surpasses the limit allow by the 94 computer) then it may be possible to generate a 95 floating point overflow from an intermediate 96 computation even though the actual cross product and 97 derivative may be well within the range of double 98 precision numbers. 99 100 dvcrss_c does NOT check the magnitude of 's1' or 's2' to 101 insure that overflow will not occur. 102 103 -Files 104 105 None. 106 107 -Particulars 108 109 dvcrss_c calculates the three-dimensional cross product of two 110 vectors and the derivative of that cross product according to 111 the definition. The components of this state are stored 112 in a local buffer vector until the calculation is complete. 113 Thus sout may overwrite 's1' or 's2' without interfering with 114 intermediate computations. 115 116 -Examples 117 118 s1 s2 sout 119 ----------------------------------------------------------------- 120 (0, 1, 0, 1, 0, 0) ( 1, 0, 0, 1, 0, 0) (0, 0, -1, 0, 0, -1 ) 121 (5, 5, 5, 1, 0, 0) (-1, -1, -1, 2, 0, 0) (0, 0, 0, 0, 11,-11 ) 122 123 -Restrictions 124 125 None. 126 127 -Literature_References 128 129 None. 130 131 -Author_and_Institution 132 133 W.L. Taber (JPL) 134 E.D. Wright (JPL) 135 136 -Version 137 138 -CSPICE Version 1.0.0, 23-NOV-2009 (EDW) 139 140 -Index_Entries 141 142 Compute the derivative of a cross product 143 144 -& 145 */ 146 147 { /* Begin dvcrss_c */ 148 149 /* 150 Local variables 151 */ 152 153 SpiceDouble vtemp [3]; 154 SpiceDouble dvtmp1[6]; 155 SpiceDouble dvtmp2[6]; 156 157 /* 158 Calculate the cross product of 's1' and 's2', store it in 'vtemp'. 159 */ 160 vcrss_c (s1, s2, vtemp ); 161 162 /* 163 Calculate the two components of the derivative of s1 x s2. 164 */ 165 vcrss_c ( &(s1[3]), s2, dvtmp1 ); 166 vcrss_c ( s1, &(s2[3]), dvtmp2 ); 167 168 /* 169 Put all of the pieces into 'sout'. 170 */ 171 vequ_c ( vtemp, sout ); 172 vadd_c ( dvtmp1, dvtmp2, &(sout[3])); 173 174 } /* End dvcrss_c */ 175 176