Table of contents
CSPICE_VADD adds two double precision 3-dimensional vectors.
Given:
v1,
v2 two arbitrary double precision 3-dimensional vectors.
help, v1
DOUBLE = Array[3]
help, v2
DOUBLE = Array[3]
the call:
cspice_vadd, v1, v2, vout
returns:
vout the double precision 3-dimensional vector sum of `v1' and `v2'.
help, vout
DOUBLE = Array[3]
None.
Any numerical results shown for this example may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
1) Define two sets of 3-dimensional vectors and compute the sum
of each vector in first set with the corresponding vector in
the second set.
Example code begins here.
PRO vadd_ex1
;;
;; Local parameters.
;;
SETSIZ = 2L
;;
;; Define the two vector sets.
;;
seta = [ [ 1.D0, 2.D0, 3.D0 ], [ 1.D-7, 1.D23, 1.D-9 ] ]
setb = [ [ 4.D0, 5.D0, 6.D0 ], [ 1.D24, 1.D23, 0.D0 ] ]
;;
;; Calculate the sum of each pair of vectors
;;
for i=0L, SETSIZ-1L do begin
cspice_vadd, seta[*,i], setb[*,i], vout
print, format='(A,3E11.2)', 'Vector A : ', seta[*,i]
print, format='(A,3E11.2)', 'Vector B : ', setb[*,i]
print, format='(A,3E11.2)', 'Sum vector: ', vout
print, ' '
endfor
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Vector A : 1.00E+00 2.00E+00 3.00E+00
Vector B : 4.00E+00 5.00E+00 6.00E+00
Sum vector: 5.00E+00 7.00E+00 9.00E+00
Vector A : 1.00E-07 1.00E+23 1.00E-09
Vector B : 1.00E+24 1.00E+23 0.00E+00
Sum vector: 1.00E+24 2.00E+23 1.00E-09
This routine simply performs addition between components of `v1'
and `v2'. No checking is performed to determine whether floating
point overflow has occurred.
Native IDL code to calculate the same vector result:
sum = vec1 + vec2
The IDL '+' operator accepts arbitrary size N vectors.
1) If any of the input arguments, `v1' or `v2', is undefined, an
error is signaled by the IDL error handling system.
2) If any of the input arguments, `v1' 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 `vout' is not a named variable, an
error is signaled by the Icy interface.
None.
1) The user is required to determine that the magnitude each
component of the vectors is within the appropriate range so as
not to cause floating point overflow.
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.0.3, 10-AUG-2021 (JDR)
Edited the header to comply with NAIF standard. Added complete
code example.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections, and
completed -Particulars section.
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)
3-dimensional vector addition
|