1 /* dvdot.f -- translated by f2c (version 19980913).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include "f2c.h"
7 
8 /* $Procedure      DVDOT  ( Derivative of Vector Dot Product, 3-D ) */
dvdot_(doublereal * s1,doublereal * s2)9 doublereal dvdot_(doublereal *s1, doublereal *s2)
10 {
11     /* System generated locals */
12     doublereal ret_val;
13 
14 /* $ Abstract */
15 
16 /*     Compute the derivative of the dot product of two double */
17 /*     precision position vectors. */
18 
19 /* $ Disclaimer */
20 
21 /*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
22 /*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
23 /*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
24 /*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
25 /*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
26 /*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
27 /*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
28 /*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
29 /*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
30 /*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
31 
32 /*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
33 /*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
34 /*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
35 /*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
36 /*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
37 /*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
38 
39 /*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
40 /*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
41 /*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
42 /*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
43 
44 /* $ Required_Reading */
45 
46 /*     None. */
47 
48 /* $ Keywords */
49 
50 /*     VECTOR */
51 /*     DERIVATIVE */
52 
53 /* $ Declarations */
54 /* $ Brief_I/O */
55 
56 /*     VARIABLE  I/O  DESCRIPTION */
57 /*     --------  ---  -------------------------------------------------- */
58 /*     S1        I     First state vector in the dot product. */
59 /*     S2        I     Second state vector in the dot product. */
60 
61 /*     The function returns the derivative of the dot product <S1,S2> */
62 
63 /* $ Detailed_Input */
64 
65 /*     S1      Any state vector.  The componets are in order */
66 /*             (x, y, z, dx/dt, dy/dt, dz/dt ) */
67 
68 /*     S2      Any state vector. */
69 
70 /* $ Detailed_Output */
71 
72 /*     The function returns the derivative of the dot product of the */
73 /*     position portions of the two state vectors S1 and S2. */
74 
75 /* $ Parameters */
76 
77 /*     None. */
78 
79 /* $ Files */
80 
81 /*     None. */
82 
83 /* $ Exceptions */
84 
85 /*     Error free. */
86 
87 /* $ Particulars */
88 
89 /*     Given two state vectors S1 and S2 made up of position and */
90 /*     velocity components (P1,V1) and (P2,V2) respectively, */
91 /*     DVDOT calculates the derivative of the dot product of P1 and P2, */
92 /*     i.e. the time derivative */
93 
94 /*           d */
95 /*           -- < P1, P2 > = < V1, P2 > + < P1, V2 > */
96 /*           dt */
97 
98 /*     where <,> denotes the dot product operation. */
99 
100 /* $ Examples */
101 
102 /*     Suppose that given two state vectors (S1 and S2)whose position */
103 /*     components are unit vectors, and that we need to compute the */
104 /*     rate of change of the angle between the two vectors. */
105 
106 /*     We know that the Cosine of the angle THETA between them is given */
107 /*     by */
108 
109 /*        COSINE(THETA) = VDOT(S1,S2) */
110 
111 /*     Thus by the chain rule, the derivative of the angle is given */
112 /*     by: */
113 
114 /*        SINE(THETA) dTHETA/dt = DVDOT(S1,S2) */
115 
116 /*     Thus for values of THETA away from zero we can compute */
117 
118 /*     dTHETA/dt as */
119 
120 /*     DTHETA = DVDOT(S1,S2) / SQRT ( 1 - VDOT(S1,S2)**2 ) */
121 
122 /*     Note that position components of S1 and S2 are parallel, the */
123 /*     derivative of the  angle between the positions does not */
124 /*     exist.  Any code that computes the derivative of the angle */
125 /*     between two position vectors should account for the case */
126 /*     when the position components are parallel. */
127 
128 /* $ Restrictions */
129 
130 /*     The user is responsible for determining that the states S1 and */
131 /*     S2 are not so large as to cause numeric overflow.  In most cases */
132 /*     this won't present a problem. */
133 
134 /* $ Author_and_Institution */
135 
136 /*     W.L. Taber      (JPL) */
137 
138 /* $ Literature_References */
139 
140 /*     None. */
141 
142 /* $ Version */
143 
144 /* -    SPICELIB Version 1.0.0, 18-MAY-1995 (WLT) */
145 
146 
147 /* -& */
148 /* $ Index_Entries */
149 
150 /*     Compute the derivative of a dot product */
151 
152 /* -& */
153 
154     ret_val = s1[0] * s2[3] + s1[1] * s2[4] + s1[2] * s2[5] + s1[3] * s2[0] +
155 	    s1[4] * s2[1] + s1[5] * s2[2];
156     return ret_val;
157 } /* dvdot_ */
158 
159