Table of contents
CSPICE_VLCOM computes a vector linear combination of two double
precision, 3-dimensional vectors.
Given:
a the double precision scalar variable that multiplies `v1'.
help, a
DOUBLE = Scalar
v1 an arbitrary, double precision 3-dimensional vector.
help, v1
DOUBLE = Array[3]
b the double precision scalar variable that multiplies `v2'.
help, b
DOUBLE = Scalar
v2 an arbitrary, double precision 3-dimensional vector.
help, v2
DOUBLE = Array[3]
the call:
cspice_vlcom, a, v1, b, v2, sum
returns:
sum the double precision 3-dimensional vector which
contains the linear combination
a * v1 + b * v2
help, sum
DOUBLE = Array[3]
None.
Any numerical results shown for these examples may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
1) Suppose you want to generate a sequence of points representing
an elliptical footprint, from the known semi-major
and semi-minor axes.
Example code begins here.
PRO vlcom_ex1
;;
;; Let `smajor' and `sminor' be the two known semi-major and
;; semi-minor axes of our elliptical footprint.
;;
smajor = [ 0.070115D0, 0.D0, 0.D0 ]
sminor = [ 0.D0, 0.035014D0, 0.D0 ]
;;
;; Compute the vectors of interest and display them
;;
theta = 0.D0
step = cspice_twopi() / 16L
for i=0L, 15L do begin
cspice_vlcom, cos(theta), smajor, sin(theta), sminor, vector
print, format='(I2,A,3F10.6)', i, ':', vector
theta = theta + step
endfor
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
0: 0.070115 0.000000 0.000000
1: 0.064778 0.013399 0.000000
2: 0.049579 0.024759 0.000000
3: 0.026832 0.032349 0.000000
4: 0.000000 0.035014 0.000000
5: -0.026832 0.032349 0.000000
6: -0.049579 0.024759 0.000000
7: -0.064778 0.013399 0.000000
8: -0.070115 0.000000 0.000000
9: -0.064778 -0.013399 -0.000000
10: -0.049579 -0.024759 -0.000000
11: -0.026832 -0.032349 -0.000000
12: -0.000000 -0.035014 -0.000000
13: 0.026832 -0.032349 0.000000
14: 0.049579 -0.024759 0.000000
15: 0.064778 -0.013399 0.000000
2) As a second example, suppose that U and V are orthonormal
vectors that form a basis of a plane. Moreover suppose that we
wish to project a vector X onto this plane.
Example code begins here.
PRO vlcom_ex2
;;
;; Let `x' be an arbitrary 3-vector
;;
x = [4.D0, 35.D0, -5.D0]
;;
;; Let `u' and `v' be orthonormal 3-vectors spanning the
;; plane of interest.
;;
u = [ 0.D0, 0.D0, 1.D0 ]
v = [ sqrt(2.D0)/2.D0, -sqrt(2.D0)/2.D0, 0.D0 ]
;;
;; Compute the projection of `x' onto this 2-dimensional
;; plane in 3-space.
;;
cspice_vlcom, cspice_vdot( x, u ), u, cspice_vdot( x, v ), v, puv
;;
;; Display the results.
;;
print, format='(A,3F6.1)', 'Input vector : ', x
print, format='(A,3F6.1)', 'Projection into 2-d plane: ', puv
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Input vector : 4.0 35.0 -5.0
Projection into 2-d plane: -15.5 15.5 -5.0
The code reflects precisely the following mathematical expression
For each value of the index `i', from 0 to 2:
sum[i] = a * v1[i] + b * v2[i]
No error checking is performed to guard against numeric overflow.
IDL native code to perform the same operation:
sum = a * v1 + b * v2
The IDL expression accepts two n-dimensional vectors.
1) If any of the input arguments, `a', `v1', `b' or `v2', is
undefined, an error is signaled by the IDL error handling
system.
2) If any of the input arguments, `a', `v1', `b' or `v2', is not
of the expected type, or it does not have the expected
dimensions and size, an error is signaled by the Icy
interface.
3) If the output argument `sum' is not a named variable, an error
is signaled by the Icy interface.
None.
1) No error checking is performed to guard against numeric
overflow or underflow. The user is responsible for insuring
that the input values are reasonable.
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.0.3, 13-AUG-2021 (JDR)
Edited the header to comply with NAIF standard. Added complete
code examples.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections, and
completed -Particulars section. Moved the contents of the existing
-Examples section to -Particulars.
Removed reference to the routine's corresponding CSPICE header from
-Abstract section.
Added arguments' type and size information in the -I/O section.
-Icy Version 1.0.2, 13-JUN-2011 (EDW)
Edits to comply with NAIF standard for Icy headers.
-Icy Version 1.0.1, 09-DEC-2005 (EDW)
Added -Examples section.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
linear combination of two 3-dimensional vectors
|