1 /*
2 
3 -Procedure      vlcom_c ( Vector linear combination, 3 dimensions )
4 
5 -Abstract
6 
7    Compute a vector linear combination of two double precision,
8    3-dimensional vectors.
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 
43 */
44 
45    #include "SpiceUsr.h"
46    #undef    vlcom_c
47 
48 
vlcom_c(SpiceDouble a,ConstSpiceDouble v1[3],SpiceDouble b,ConstSpiceDouble v2[3],SpiceDouble sum[3])49    void vlcom_c ( SpiceDouble        a,
50                   ConstSpiceDouble   v1[3],
51                   SpiceDouble        b,
52                   ConstSpiceDouble   v2[3],
53                   SpiceDouble        sum[3] )
54 /*
55 
56 -Brief_I/O
57 
58    VARIABLE  I/O  DESCRIPTION
59    --------  ---  --------------------------------------------------
60    a          I   Coefficient of v1
61    v1         I   Vector in 3-space
62    b          I   Coefficient of v2
63    v2         I   Vector in 3-space
64    sum        O   Linear Vector Combination a*v1 + b*v2
65 
66 -Detailed_Input
67 
68    a     This double precision variable multiplies v1.
69    v1    This is an arbitrary, double precision 3-dimensional
70           vector.
71    b     This double precision variable multiplies v2.
72    v2    This is an arbitrary, double precision 3-dimensional
73           vector.
74 
75 -Detailed_Output
76 
77    sum   is an arbitrary, double precision 3-dimensional vector
78           which contains the linear combination a*v1 + b*v2.
79 
80 -Parameters
81 
82    None.
83 
84 -Particulars
85 
86    For each index from 0 to 2, this routine implements in C
87    code the expression:
88 
89    sum[i] = a*v1[i] + b*v2[i]
90 
91    No error checking is performed to guard against numeric overflow.
92 
93 -Examples
94 
95    To generate a sequence of points on an ellipse with major
96    and minor axis vectors major and minor, one could use the
97    following code fragment
98 
99           step = twopi_c()/ n;
100           ang  = 0.0;
101 
102           for ( i = 0; i < n; i++ )
103              {
104              vlcom_c ( cos(ang),major,  sin(ang),minor,  point );
105 
106              do something with the ellipse point just constructed
107 
108              ang = ang + step;
109              }
110 
111    As a second example, suppose that u and v are orthonormal vectors
112    that form a basis of a plane. Moreover suppose that we wish to
113    project a vector x onto this plane, we could use the following
114    call inserts this projection into proj.
115 
116           vlcom_c ( vdot_c(x,v),v,   vdot_c(x,u),u,    proj )
117 
118 
119 -Restrictions
120 
121    No error checking is performed to guard against numeric overflow
122    or underflow.  The user is responsible for insuring that the
123    input values are reasonable.
124 
125 -Exceptions
126 
127    Error free.
128 
129 -Files
130 
131    None
132 
133 -Author_and_Institution
134 
135    W.L. Taber      (JPL)
136    E.D. Wright     (JPL)
137 
138 -Literature_References
139 
140    None
141 
142 -Version
143 
144    -CSPICE Version 1.1.0, 22-OCT-1998 (NJB)
145 
146       Made input vectors const.
147 
148    -CSPICE Version 1.0.0, 08-FEB-1998 (EDW)
149 
150 -Index_Entries
151 
152    linear combination of two 3-dimensional vectors
153 
154 -&
155 */
156 
157 { /* Begin vlcom_c */
158 
159    /* This really doesn't require a degree in rocket science */
160 
161    sum[0] = a*v1[0] + b*v2[0];
162    sum[1] = a*v1[1] + b*v2[1];
163    sum[2] = a*v1[2] + b*v2[2];
164 
165 
166 } /* End vlcom_c */
167