[Previous]
[Next]
NAME:
vectorproduct
PURPOSE:
Calculate vector or scalar product for two vectors
CATEGORY:
gen/idl/toolbox/math
CALLING SEQUENCE:
result = vectorproduct(r1, r2 [, /unit, /cylin, /sphere, /rect, /degrees, /scalar, /angle])
INPUTS:
r1 arrays[3,*]; type: int or float
r1 arrays[3,*]; type: int or float
vectors for which the product is to be taken.
the first dimension identifies the three coordinates: Cartesian (default),
cylindrical or spherical.
OPTIONAL INPUT PARAMETERS:
/scalar by default the vector (cross-product) is calculated. If /scalar is set
then the scalar product is calculated instead.
/angle if set then information about the angle between the two vectors is returned:
for vector products sin(angle) = |r1 x r2|/|r1||r2|
for scalar products cos(angle) = |r1.r2|/|r1||r2|
/unit if set, then a unit vector along the cross-product vector is returned
(keyword not used if /scalar is set)
/cylin, /sphere, /rect
indicates whether input vectors are in cylindrical, spherical or rectangular
coordinates. If none is set then rectangular is assumed.
For cross-products the output vectors are in the same units as the input vectors.
/degrees if set, and spherical or cylindrical coordinates are used, then the angles
are assumed to be in degrees (default: radians)
OUTPUTS:
result array[3,*] or array[*] same type as input
cross-products are returned as array[3,*] (same as the input arrays)
scalar products or angle information are returned as array[n]
OPTIONAL OUTPUT PARAMETERS:
INCLUDE:
@compile_opt.pro ; On error, return to caller
CALLS: ***
CV_COORD, InitVar, SyncArgs, SyncDims
CALLED BY:
PlotSolarDisk, plot3darc, sgp4_orbit_axis, unitvectors
PROCEDURE:
> The arrays r1 and r2 do not necessarily have the same dimensions, i.e.
if r1 is an array[3,n] and r2 is an array[3] then r2 is interpreted as an array[3,n]
with all n vectors the same (SyncArgs is used to synchronize the array dimensions).
> Arrays r1 and r2 can have more than two dimensions, i.e. if r1 and r2 are both
arrays[3,n,m] then the output cross-vectors also will be an array[3,n,m] while scalar
products will be returned as array[n,m]
MODIFICATION HISTORY:
AUG-1999, Paul Hick (UCSD/CASS; pphick@ucsd.edu)