func makebox, image, x0, x1, y0, y1, w
 ;given a 2-D image and coordinates along the center line of the
 ;desired rectangle, extract a rectangle of width w
 nx = dimen(image,0)  ;first dimension of image
 ;get length of line
 d = sqrt( (x0-x1)^2 + (y0-y1)^2 )
 dx = (x0-x1)
 dy = (y0-y1)
 dxp = -dy*w/2./d
 dyp = dx*w/2./d
 xb = x0-dxp
 yb = y0-dyp
 dxp = -dy/d
 dyp = dx/d
 nxb = rfix(w)
 nyb = rfix(d)
 ;;xi = indgen(intarr(w,rfix(d)),0)
 ;;yi = indgen(intarr(w,rfix(d)),1)
 ;get a rectangular array for destination
 xi = lonarr(nxb, nyb)
 xi = indgen(xi)
 yi = xi
 xi = xi % nxb
 yi = yi/nxb
 ;now load with locations in image
 xc = rfix(xb)+xi*dxp-yi*dyp
 yc = rfix(yb)+yi*dxp+xi*dyp
 xc = rfix(xc)     yc=rfix(yc)
 result = image( xc + yc*nx)
 return, result
 endfunc

 
