!-----------------------------------------------------------------------
!  nb0loc  evaluate position and lab frame velocity of fast neutral
!
!
subroutine nb0loc(zltrav,zsinth,zcosth,zsinph,zcosph, &
     zxhor,zyhor,zr,zy,zvtor,zvr,zvy)
  !
  use nbi_com
  !
  !
  !  input arguments
  !   zltrav - trajectory length from trkrb starting pt (rsta,ysta)
  !            to current location
  !   zsinth,zcosth,zsinph,zcosph:  sin and cos of thea, phia
  !            (trkrb direction angles)
  !
  !  common  (rsta,ysta)  starting location of neutral track
  !            vion       speed of neutral ptcl
  !
  !  output arguments
  !   (zxhor,zyhor) position projected onto midplane, relative to start point
  !        (rsta,0); zr = sqrt(zxhor**2+zyhor**2)
  !   (zr,zy)  location of neutral (dist. from machine axis, elevation)
  !   (zvtor,zvr,zvy)  lab frame velocity vector
  !     toroidal component, radial component, vertical component
  !
  !--------------------------------------------
  !
  !  ptcl position in (r,y)
  !
  !============
  implicit none
  real(fp) :: zr,zy,zvtor,zvr,zvy,zltrav,zlnhor,zvhor,zsina
  real(fp) :: zcosa,zsinth,zcosth,zsinph,zcosph,zxhor,zyhor
  !============
  zy=ysta+zltrav*zsinth
  !
  zlnhor=zltrav*zcosth
  !
  zxhor=rsta-zlnhor*zcosph
  zyhor=zlnhor*zsinph
  !
  zr=sqrt(zxhor*zxhor+zyhor*zyhor)
  !
  !  ptcl velocity components, lab frame
  !
  zvy=vion*zsinth
  !
  zvhor=vion*zcosth
  !
  zsina=zyhor/zr
  zcosa=zxhor/zr
  !
  zvr=zvhor*(zsinph*zsina-zcosph*zcosa)
  zvtor=zvhor*(zsinph*zcosa+zcosph*zsina)
  !
  return
end subroutine nb0loc
