Table of contents
CSPICE_VSUB computes the difference between two double precision
3-dimensional vectors.
Given:
v1 a double precision 3-dimensional vector which is the minuend
(i.e.
help, v1
DOUBLE = Array[3]
first or left-hand member) in the vector subtraction.
v2 a double precision 3-dimensional vector which is the subtrahend
(i.e.
help, v2
DOUBLE = Array[3]
second or right-hand member) in the vector subtraction.
the call:
cspice_vsub, v1, v2, vout
returns:
vout a double precision 3-dimensional vector which represents the
vector difference, v1 - 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
difference from each vector in first set with the
corresponding vector in the second set.
Example code begins here.
PRO vsub_ex1
;;
;; Local parameters.
;;
SETSIZ = 3L
;;
;; Define the two vector sets.
;;
v1 = [ [ 1.D0, 2.D0, 3.D0 ], $
[ 1.D0, 2.D0, 3.D0 ], $
[ 1.D0, 2.D0, 3.D0 ] ]
v2 = [ [ 1.D0, 1.D0, 1.D0 ], $
[-1.D0, -2.D0, -3.D0 ], $
[-1.D0, 2.D0, -3.D0 ] ]
;;
;; Calculate the difference between each pair of vectors
;;
for i=0L, SETSIZ-1L do begin
cspice_vsubg, v1[*,i], v2[*,i], vout
print, format='(A,3F6.1)', 'First vector : ', v1[*,i]
print, format='(A,3F6.1)', 'Second vector: ', v2[*,i]
print, format='(A,3F6.1)', 'Difference : ', vout
print
endfor
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
First vector : 1.0 2.0 3.0
Second vector: 1.0 1.0 1.0
Difference : 0.0 1.0 2.0
First vector : 1.0 2.0 3.0
Second vector: -1.0 -2.0 -3.0
Difference : 2.0 4.0 6.0
First vector : 1.0 2.0 3.0
Second vector: -1.0 2.0 -3.0
Difference : 2.0 0.0 6.0
For each value of the index `i' from 0 to 2, this routine performs
the following subtraction:
vout[i] = v1[i] - v2[i]
No error checking is performed to guard against numeric overflow
or underflow.
Native IDL code to calculate the same vector result:
vout = v1 - v2
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. No error recovery or
reporting scheme is incorporated in this routine.
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.0.4, 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. Moved the existing contents of -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.3, 13-JUN-2011 (EDW)
Edits to comply with NAIF standard for Icy headers.
-Icy Version 1.0.2, 23-SEP-2008 (EDW)
Eliminated English error.
-Icy Version 1.0.1, 09-DEC-2005 (EDW)
Added -Examples section.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
3-dimensional vector subtraction
|