home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best Objectech Shareware Selections
/
UNTITLED.iso
/
boss
/
data
/
dbas
/
004
/
navigate.prg
< prev
next >
Wrap
Text File
|
1992-06-25
|
29KB
|
751 lines
*-------------------------------------------------------------------------------
*-- Program...: NAVIGATE.PRG
*-- Programmer: Ken Mayer (KENMAYER)
*-- Date......: 06/25/1992
*-- Notes.....: These are interesting functions designed to help out in
*-- navigation ... see the file: README.TXT for details on the
*-- use of this library file.
*-- NOTE -- a few functions have been added into this library
*-- that are duplicated elsewhere (other library files). This is
*-- due to a limitation with dBASE IV, 1.5's handling of libraries.
*-- These functions are (and are from):
*-- STRIP2VAL() from STRINGS.PRG
*-- STRIPVAL()
*-- STRPBRK()
*-- HAV() from TRIG.PRG
*-- AHAV()
*-- CSCH()
*-- SINH()
*-------------------------------------------------------------------------------
FUNCTION Correct
*-------------------------------------------------------------------------------
*-- Programmer..: Jay Parsons (JPARSONS)
*-- Date........: 03/01/1992
*-- Notes.......: Correction of direction - adjusts direction given, in degrees,
*-- by second number of degrees. Use to convert a compass
*-- direction to magnetic using deviation as the second argument,
*-- or magnetic to true using variation as the second argument.
*-- Returns a direction in degrees.
*--
*-- A westerly second argument may be given either as a negative
*-- number or as a character value containing "W". If second
*-- argument is character-type but contains a negative value,
*-- effect of presence or absence of "W" is reversed. That is,
*-- "-20 W" is treated like "20 E" or the number 20.
*-- Written for.: dBASE IV, 1.1
*-- Rev. History: None
*-- Calls.......: None
*-- Called by...: Any
*-- Usage.......: Correct(<nDirection>,<xCorrection>)
*-- Example.....: ?Correct(50,"-10 E")
*-- Returns.....: Numeric (direction in degrees)
*-- Parameters..: nDirection = Heading
*-- xCorrection = amount to 'correct' by, may be numeric or
*-- character, see above under 'Notes'.
*-------------------------------------------------------------------------------
parameters nDirection, xCorrection
private nCval
if type( "xCorrection" ) = "C"
nCval = val( xCorrection )
if "W" $ upper( xCorrection )
nCval = - nCval
endif
else
nCval = xCorrection
endif
RETURN mod( 360 + nDirection + nCval, 360 )
*-- EoF: Correct()
FUNCTION UnCorrect
*-------------------------------------------------------------------------------
*-- Programmer..: Jay Parsons (JPARSONS)
*-- Date........: 03/01/1992
*-- Notes.......: Uncorrection of direction - adjusts direction given, in
*-- degrees, by second number of degrees. The inverse of
*-- correct(), see above. Use to convert a true direction to
*-- magnetic using variation as the second argument, or magnetic
*-- to compass using deviation as the second argument.
*-- Written for.: dBASE IV, 1.1
*-- Rev. History: None
*-- Calls.......: None
*-- Called by...: Any
*-- Usage.......: UnCorrect(<nDirection>,<xUnCorr>)
*-- Example.....: ?UnCorrect(50,"-10 E")
*-- Returns.....: Numeric (direction in degrees)
*-- Parameters..: nDirection = Heading
*-- xUnCorr = amount to 'uncorrect' by, may be numeric or
*-- character, see above under 'Notes'.
*-------------------------------------------------------------------------------
parameters nDirection, xUncorr
private nCval
if type( "xUncorr" ) = "C"
nCval = val( xUncorr )
if "W" $ upper( xUncorr )
nCval = - nCval
endif
else
nCval = xUncorr
endif
RETURN mod( 360 + nDirection - nCval, 360 )
*-- EoF: UnCorrect()
FUNCTION XAngle
*-------------------------------------------------------------------------------
*-- Programmer..: Jay Parsons (JPARSONS)
*-- Date........: 03/01/1992
*-- Notes.......: Angle in degrees ( <= 90 ) at which two vectors in
*-- degrees intersect.
*-- Written for.: dBASE IV, 1.1
*-- Rev. History: None
*-- Calls.......: None
*-- Called by...: Any
*-- Usage.......: XAngle(<nVector1>,<nVector2>)
*-- Example.....: ?UnCorrect(20,240)
*-- Returns.....: Numeric (direction in degrees)
*-- Parameters..: nVector1 = First angle
*-- nVector2 = Second angle
*-------------------------------------------------------------------------------
parameters nVector1, nVector2
private nResult
nResult = abs( nVector1 - nVector2)
do case
case nResult > 270
nResult = 360 - Result
case nResult > 180
nResult = nResult - 180
case nResult > 90
nResult = 180 - nResult
endcase
RETURN nResult
*-- EoF: XAngle()
FUNCTION LeftWind
*-------------------------------------------------------------------------------
*-- Programmer..: Jay Parsons (JPARSONS)
*-- Date........: 03/01/1992
*-- Notes.......: Whether effect of second vector on first is from the
*-- left or the right. Returns .T. if from the left, else .F.
*-- Expects vectors in degrees.
*--
*-- For convenience in aviation calculations, the second
*-- argument is expected as the direction FROM which
*-- the wind or current is coming, not the direction TO
*-- which it is going. If the contrary sense
*-- is more convenient, change the "=" sign in the
*-- function to "#".
*-- Written for.: dBASE IV, 1.1
*-- Rev. History: None
*-- Calls.......: None
*-- Called by...: Any
*-- Usage.......: LeftWind(<nCourse>,<nWindFrom>)
*-- Example.....: ?LeftWind(20,240)
*-- Returns.....: Numeric (direction in degrees)
*-- Parameters..: nCourse = Direction of heading ...
*-- nWindFrom = Direction wind or current is coming from
*-------------------------------------------------------------------------------
parameters nCourse, nWindfrom
RETURN ( nCourse > nWindfrom ) = ( abs( nCourse - nWindfrom ) < 180 )
*-- EoF: LeftWind()
FUNCTION TailWind
*-------------------------------------------------------------------------------
*-- Programmer..: Jay Parsons (JPARSONS)
*-- Date........: 03/01/1992
*-- Notes.......: Whether effect of second vector on first is additive
*-- or subtractive ( from behind or from ahead ).
*--
*-- For convenience in aviation calculations, the second
*-- argument is expected as the direction FROM which
*-- the wind or current is coming, not the direction TO
*-- which is going. If the contrary sense
*-- is more convenient, change the "<" sign in the
*-- function to ">".
*-- Written for.: dBASE IV, 1.1
*-- Rev. History: None
*-- Calls.......: None
*-- Called by...: Any
*-- Usage.......: TailWind(<nCourse>,<nWindFrom>)
*-- Example.....: ?TailWind(20,240)
*-- Returns.....: Numeric (direction in degrees)
*-- Parameters..: nCourse = Direction of heading ...
*-- nWindFrom = Direction wind or current is coming from
*-------------------------------------------------------------------------------
parameters nCourse, nWindfrom
RETURN ( abs( abs( nCourse - nWindfrom ) - 180 ) < 90 )
*-- EoF: TailWind()
FUNCTION Heading
*-------------------------------------------------------------------------------
*-- Programmer..: Jay Parsons (JPARSONS)
*-- Date........: 03/01/1992
*-- Notes.......: Heading required to make good a course.
*-- If using this for boating and the direction of set is
*-- more convenient than the direction from which
*-- it is coming, apply mod( 180 + direction, 360 )
*-- to the fourth argument before calling.
*-- Written for.: dBASE IV, 1.1
*-- Rev. History: None
*-- Calls..