%%HP: T(3)A(D)F(.);
\<<

@ Program to compute dip and strike
@ from three bore hole positions
@ and bore depths

@ Conventions
@ Bores A, B, C are anti-clockwise in plan view 

@ Enter bore co-ordinates

"Bore Hole A"
{":Easting :
:Northing:
:Height  :"
{ 1 0 } }
INPUT OBJ\->

"Bore Hole B"
{":Easting :
:Northing:
:Height  :"
{ 1 0 } }
INPUT OBJ\->

"Bore Hole C"
{":Easting :
:Northing:
:Height  :"
{ 1 0 } }
INPUT OBJ\->

"Depths to Seam"
{":Bore A:
:Bore B:
:Bore C:"
{ 1 0 } }
INPUT OBJ\->

@ Store as local variables
\-> ea na za eb nb zb ec nc zc da db dc
\<<
@ Compute z co-ordinates defining seam plane
za da - 'za' STO
zb db - 'zb' STO
zc dc - 'zc' STO

@ Orientate plane where za is the highest z co-ordinate
IF zb za > THEN 
eb nb zb ec nc zc ea na za
'zc' STO 'nc' STO 'ec' STO 'zb' STO 'nb' STO 'eb' STO
'za' STO 'na' STO 'ea' STO
END

IF zb za > THEN
eb nb zb ec nc zc ea na za
'zc' STO 'nc' STO 'ec' STO 'zb' STO 'nb' STO 'eb' STO
'za' STO 'na' STO 'ea' STO
END

@ Compute vector normal to plane coefficients

@ compute i coefficient of normal
nb na - zc za - *
nc na - zb za - * -

@ compute j coefficient of normal
eb ea - zc za - *
ec ea - zb za - * - NEG

@ compute k coefficient of normal
eb ea - nc na - *
ec ea - nb na - * -

@ Store as local variables 
\-> i j k
\<<

@ Compute elevation angle of normal
@ Set Degrees mode
DEG
i SQ j SQ + \v/ k SWAP / ATAN

@ Subtract 90 degrees to compute dip
90 -

@ Compute bearing of strike
j i RECT \->V2 CYLIN  V\-> SWAP DROP RECT
DUP IF 0 < THEN 360 + END

@ Display results

" 
DIP ANGLE = " ROT \->HMS DMS 4 FIX +
"
STRIKE    = " + SWAP \->HMS DMS +
CLLCD 1 DISP 3 FREEZE 0 WAIT DROP

\>>



\>>
\>>
