Function: ANGLE
Purpose: Calculate angle in radians between two points given in grids
File: angle.c
Author: M. Vogelaar
Use: DOUBLE ANGLE( SET, Input CHARACTER*(*)
SUBSET, Input INTEGER
AXNUM , Input INTEGER
GRID1, Input DOUBLE PRECISION ARRAY
GRID2, Input DOUBLE PRECISION ARRAY
ERR ) Output INTEGER
ANGLE Spatial distance between GRID1 and GRID2 in radians.
SET Name of GDS set.
SUBSET Subset in which grids are specified.
AXNUM Array containing the axis numbers.
GRID1 Grid position in subset.
GRID2 Second grid position in subset. Between these
grids, the spatial distance will be calculated.
ERR If an error occurred, the error code is returned in ERR and
for the angle a double precision blank is substituted.
Positive error numbers correspond to COTRANS errors. The
negative values have different origin.
ERR = -20 No conversion to DEGREE could be made
ERR = -21 Could not find units
ERR = -22 No spatial axes in subset.
Description: ANGLE calculates the spatial distance between two grids.
The grids are entered as double precision numbers in GRID1
and GRID2. The dimension of the grid arrays is equal to the
dimension of the subset. The axis permutation array AXNUM
is the same axis permutation array as created by GDSINP. If
there is at least one spatial axis in the subset, a distance
in radians can be calculated. If no coordinate transformation
is possible, an error number (corresponding to COTRANS error
numbers) is returned (all > 0). Negative errors are returned
if something is wrong with the units, or if there is no
spatial axis in the subset. Then a double precision blank
is returned in ANGLE.
Example:
maxpos = 1;
dfault = NONE;
Key = tofchar("START=");
Mes = tofchar("Give start position (x0,x1,..xn):");
numpos = gdspos_c(start, &maxpos, &dfault, Key, Mes, Setin, &subin[0]);
Key = tofchar("END=");
Mes = tofchar("Give end position (y0,y1,..yn):");
numpos = gdspos_c(end, &maxpos, &dfault, Key, Mes, Setin, &subin[0]);
myangle = angle_c( Setin, &subin[0], axnum, start, end, &r1 );
if (r1 == 0) (void) sprintf( message,
"Angle = %f Radians %f degree",
myangle, DEG(myangle) );
Updates: Aug 12, 1993: VOG, Document in system