# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "<stdin>"
module steering3d
  use helix
  implicit none
  integer, private :: n1,n2 ! helix period
  real, private :: hw1,hw2, dc1,dc2
  ! triangle half-width, filter d.c.
  contains
  subroutine steer3d_init( hwidth, amp, n)
    real, intent( in) :: hwidth(2), amp(2)
    integer, intent( in) :: n(2)
    hw1 = hwidth(1)
    dc1 = amp(1)
    n1 = n(1)
    hw2 = hwidth(2)
    dc2 = amp(2)
    n2 = n(2)
  end subroutine
  subroutine create_steer3d_op(slope,filt1,filt2)
    real :: slope(2)
    type(filter) :: filt1,filt2
    call steering3d_op(slope(1),n1,filt1,hw1,dc1)
    call steering3d_op(slope(2),n1*n2,filt2,hw2,dc2)
  end subroutine
  subroutine steering3d_op( slope,n,aa,hw,dc)
    type( filter) :: aa
    real, intent( in) :: slope
    integer :: h, nh,ibig,ismall,n
    real :: p0,center ,hw,dc
    nh = size( aa%lag)
    center=n+slope
    do h = 1, nh
      aa%lag(h) = ceiling(center- real(nh)/2.)-1+h
      aa%flt(h) = abs(hw-abs(real(aa%lag(h))-center))/hw
    end do
    aa%flt = -dc/sum( aa%flt)*aa%flt
  end subroutine
end module
