comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: slice of 2D surface
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: slice of 2D surface [message #32689] Wed, 30 October 2002 10:19
Med Bennett is currently offline  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
[Message index]
 
Read Message
Previous Topic: do SMOOTH not on all data
Next Topic: Re: IDL 5.6 Where?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:34:09 PDT 2025

Total time taken to generate the page: 0.00601 seconds