'MATHTRIG.INC
=============

def asind deg(asin(%1))

def acosd  deg(acos(%1))

def atand deg(atan(%1))

def sind sin(rad(%1))

def cosd cos(rad(%1))

def tand tan(rad(%1))
'

def show
  print "%1:" tab str(%1,1) tab %2  cr
end def

def showr
  print "%1:" tab str(r*(%1),1) tab %2 cr
end def

def hline
  print string(40,"-") cr
end def

def heading
  hline
  print %1 cr
  hline
end def

def ShowCalc
  print "%1" cr
  %1
  print "%2:" tab str(%2,3) tab %3  cr
end def

'

function IsTriangle(float a,b,c) as int
=======================================
'return -1 if sides a b c can form atriangle
if a+b>c
  if b+c>a
    if a+c>b
      return -1
    endif
  endif
endif
end function


procedure Triangulate(float a,b,c,*d,*h)
========================================
'Calculate height of triangle from sides.
'
'a left side
'b right side
'c base
'd base of left rt-angle triangle component
'h height
'
d=( (a*a)-(b*b)+(c*c) ) / (2.0*c)
h=sqrt( (a*a)-(d*d) ) 'Pythagoras
end procedure


procedure Heron(float a,b,c,*d,*h)
=================================
'Calculate height of triangle from sides.
'Using Heron's Formula
'
'a left side
'b right side
'c base
'd base of left rt-angle triangle component
'h height
'
float s 'semi perimeter
float r 'area
'
s=0.5*(a+b+c)
r=sqrt( s*(s-a)*(s-b)*(s-c) ) 'Heron
h=2.0*r/c
d=sqrt( (a*a)-(h*h) ) 'Pythagoras
end procedure


procedure ridge(float a,e,*b)
=============================
'a base radial angle
'e bend angle
'b ridge angle
b=atand( tand(a)*sind(e) )
end procedure


procedure TailBend(float a,b,*w,*h,*s)
======================================
float d
w=sind(a)
d=w*tand(b)
h=d/tand(b)
s=d/sind(b)
end procedure


procedure conefacet(float r,a,e, *l,*b,*f,*v)
=============================================
'r base radius
'a base angle
'e face slope angle
'l length
'b edge angle
'f edge slope
'v ridge angle
'
float s,u,w
'
l=r/cosd(e)
w=r*sind(a)
b=atand(w,l)
s=l/cosd(b)
f=acosd(r/s)
u=tand(a)'*sind(f)
v=atand(u)
'
end procedure


