'
'----------------------------
'--- Creation information ---
'----------------------------
'
'Name: balar.ave
'Version: 1.0
'Date: 01/11/97
'Author: Ferdi Hellweger
'        Center for Research in Water Resources
'        The University of Texas at Austin
'        ferdi@crwr.utexas.edu
'
'This is a modified version of the arrow program originaly developed
'by Ye Zichuan.
'
'---------------------------
'--- Purpose/Description ---
'---------------------------
'
'This plots a vector.
'
'----------------------
'--- Get parameters ---
'----------------------
'
fx = self.Get(0)
fy = self.Get(1)
tx  = self.Get(2)
ty = self.Get(3)
length = self.get(4)
fraction = self.get(5)
len = self.get(6)
pm = self.get(7)
ps = self.get(8)
vgraphics = self.get(9)
pc = self.get(10)
'
'----------------------------------
'--- Calculate arrow from-point ---
'----------------------------------
'
cx = fx + ((tx - fx) * fraction)
cy = fy + ((ty - fy) * fraction)
'
cpt = point.make(cx,cy)
'
'-------------------------------
'--- Calculate vector length ---
'-------------------------------
'
pl = pm * ps
'
'--------------------------------
'--- Calculate arrow to-point ---
'--------------------------------
'
'alpha = sharp angle line makes with vertical
'beta = sharp angle flux vector maces with vertical
'
'line points top right
if ((fx <= tx) and (fy <= ty)) then
    alpha = ((ty - fy) / length).acos
    beta = (3.141592654 / 2) - alpha
    nx = cx + (beta.sin * pl)
    ny = cy - (beta.cos * pl)
end
'line points bottom right
if ((fx <= tx) and (fy >= ty)) then
    alpha = ((fy - ty) / length).acos
    beta = (3.141592654 / 2) - alpha
    nx = cx - (beta.sin * pl)
    ny = cy - (beta.cos * pl)
end
'line points top left
if ((fx >= tx) and (fy <= ty)) then
    alpha = ((ty - fy) / length).acos
    beta = (3.141592654 / 2) - alpha
    nx = cx + (beta.sin * pl)
    ny = cy + (beta.cos * pl)
end
'line points bottom left
if ((fx >= tx) and (fy >= ty)) then
    alpha = ((fy - ty) / length).acos
    beta = (3.141592654 / 2) - alpha
    nx = cx - (beta.sin * pl)
    ny = cy + (beta.cos * pl)
end
'
npt = point.make(nx,ny)
'
'------------------------------
'--- Claculate Vector Shape ---
'------------------------------
'
theta = 15.asradians
'
xshift = len * (theta.cos)
yshift = len * (theta.sin)
totLength = (((ny-cy)^2)+((nx-cx)^2)).Sqrt
' point along the line
p1 = ((1.0 - (xshift/totLength)) * nx) + ((xshift/totLength) * cx) 
p2 = ((1.0 - (xshift/totLength)) * ny) + ((xshift/totLength) * cy)
pi = Number.GetPI
if (cx <> nx) then
  slope = (cy - ny) / (cx - nx)
  slant = (slope/(((slope^2)+1).Sqrt)).ASin
else
  slant = pi/2.0
end
a1 = p1 - (yshift * (slant.sin))
a2 = p2 + (yshift * (slant.cos))
b1 = p1 + (yshift * (slant.sin))
b2 = p2 - (yshift * (slant.cos))
lpnt = Point.Make(a1,a2)
rpnt = Point.Make(b1,b2)
aPolyLine = PolyLine.Make({{lpnt,npt},{npt,rpnt},{rpnt,lpnt}, {cpt,npt}})
qvline = GraphicShape.Make(aPolyLine)
'
'------------------------
'--- Set vector color ---
'------------------------
'
qvsym=qvline.getsymbol
qvsym.setcolor(pc)
'
'-------------------
'--- Draw vector ---
'-------------------
'
vgraphics.add(qvline)
'
'-----------
'--- End ---
'-----------
'