Re: slice of 2D surface [message #32689] |
Wed, 30 October 2002 10:19 |
Med Bennett
Messages: 109 Registered: April 1997
|
Senior Member |
|
|
Bob Jenkins wrote:
> My data is given by x,y,z coords (i.e. 3 independent vectors). I've
> made a 2D surface using the surface func. How can I take slices of
> the resulting surface? I'm not able to use the slicer3 func since
> apparently it only works for true 3D volumes. Thanks.
Here's my function to do this -
;procedure to generate cross-section from ax,ay to
;bx,by surface grid
function xsecf,grid,xax,yax,ax,ay,bx,by,n
;grid is the 2-D surface
;xax is the array with x coordinates of the surface
;yax " y "
;ax,ay,bx,by are the x and y coordinates of the
; end points of the section you want
;n is the number of points you want along section line
xs=fltarr(n) ;array for result
dx=bx-ax
dy=by-ay
delx=dx/(n-1.) ;incremental distance in x
dely=dy/(n-1.) ;incremental distance in y
xsinc=sqrt(delx^2 + dely^2)
xsxax=findgen(n)*xsinc
print,'cross-section increment',xsinc
for i=0,n-1 do begin
px = ax + i*delx ;compute coords of each point on x-section
py = ay + i*dely
wx = where(xax le px,cx) ;find indices of southwest corner
;of the cell in which the point falls
wy = where(yax le py,cy)
wx = wx(cx-1)
wy = wy(cy-1)
;get x,y,z coords of four corners :
gx = [xax(wx),xax(wx),xax(wx+1),xax(wx+1)]
gy = [yax(wy),yax(wy+1),yax(wy+1),yax(wy)]
gz = [grid(wx,wy),grid(wx,wy+1), $
grid(wx+1,wy+1),grid(wx+1,wy)]
gdist = sqrt( (px-gx)^2 + (py-gy)^2 ) > 0.01
pz = total(gz*((1./gdist^2)/total(1./gdist^2)))
xs(i)=pz
endfor
;plot,xsxax,xs
return,xs
end
|
|
|