[Previous]
[Next]
NAME:
Distance2Line
PURPOSE:
Calculates the distance of a point to a line for points and lines in the x-y plane
CATEGORY:
Tricks
CALLING SEQUENCE:
d = Distance2Line(line, point, [,/close])
INPUTS:
line array[2,n]; type: any
array of points (x,y coordinates) defining line(s)
There should be at least 2 points (n>=2)
pointx if only pointx is specified:
array[2,m1,m2,...]; type: any
points to be tested
if both pointx and pointy are specified:
pointx array[m1]
x-coordinates of points to be tested
pointy array[m2]
y-coordinates of points to be tested
if /grid is not set then m1 MUST be equal to m2
if /grid is set then each x-coordinate is combined with
each y-coordinate to cover an m1 x m2 grid of points
OPTIONAL INPUT PARAMETERS:
/close_area adds first point of 'line' array to the end of the array
(this effectively 'closes' the curve described by the 'line' array).
/grid (only used if both pointx and pointy are used)
OUTPUTS:
d array[n',m1,m2,...]
n'=n-1 if /close_area not set
n'=n if /close_area set
OPTIONAL OUTPUT PARAMETERS:
INCLUDE:
@compile_opt.pro ; On error, return to caller
CALLS: ***
SubArray, SuperArray, SyncDims
RESTRICTIONS:
If the 'line' array represents a boundary of an area in the x-y plane with a simple
enough shape then this procedure can be used to find points inside the closed area.
If 'line' runs in the clockwise/counter-clockwise direction around the area then all
distances will be positive/negative for points inside the closed area.
'Simple enough shape' means that the curvature should be in the same sense everywhere.
PROCEDURE:
> Each pair of points line[*,i] and line[*,i+1] (i=0,n-1) defines a line in the
x-y plane. If /close_area is set then an additional pair line[*,n], line[*,0]
is defined.
> For each point in the 'point' array the distance to each of the lines is
calculated. The distance is positive it the point is toward the right of the line when
looking from line[*,i] to line[*,i+1], and negative on the other side.
> If vectors r1 and r2 correspond to points line[*,i] and line[*,i+1], respectively, and
vector p corresponds to a point then the distance calculated as
(r2-p)x(r1-p).z/|r2-r1| (z is a unit vector in the z-direction)
MODIFICATION HISTORY:
JAN-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
Distance2Sun
PURPOSE:
Calulates Electron-Sun distance and angle Sun-Electron-Observer
CALLING SEQUENCE:
FUNCTION Distance2Sun, Elo, S, SinChi, degrees=Degrees, grid=grid
INPUTS:
Elo array; type: float
elongations of lines of sight
S array; type: float
Distance along line of sight (i.e. Observer-Electron
distance) in units of the Observer-Sun distance.
If /grid NOT set then S should have the same structure
as 'Elo'. If /grid is set then any array is allowed.
OPTIONAL INPUT PARAMETERS:
/degree if set all angles are in degrees (default: radians)
/grid if set then every element in S is combined with
every element in Elo
OUTPUTS:
Result array; type: float
Sun-Electron distance (same units as S)
SinChi array; type: float
Sine of angle Sun-Electron-Observer
INCLUDE:
@compile_opt.pro ; On error, return to caller
CALLS: ***
InitVar, SuperArray, ToRadians
CALLED BY:
ThomsonLOSStep, ThomsonTang, ThomsonTangMRad
PROCEDURE:
> The elongation is the angle between observer-Sun and observer-electron
direction (Elo = 0 is the direction observer-Sun)
> Cosine and sine rule in triangle with Sun, Observer and Electron on the corners.
MODIFICATION HISTORY:
SEP-1996, Paul Hick (UCSD)
JUN-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Replacement for old ElSunDistance function
Added /grid keyword