Boris V. Khattatov (boris@ucar.edu) writes:
> Does anyone know a way to display 3-D objects
> on a map projection?
>
> It's easy to display a 2-D field in lat & lon using
> TV and MAP_IMAGE, but how can I display a
> 3-D object in lat, lon, and z in map coordinates?
I offer this code totally (and I hope uncharacteristically)
without comment. :-)
Cheers,
David
-----------------------------------------------------------
PRO Example
; Create a sphere.
SPHERE = FLTARR(20, 20, 20)
FOR X=0,19 DO FOR Y=0,19 DO FOR Z=0,19 DO $
SPHERE(X, Y, Z) = SQRT((X-10)^2 + (Y-10)^2 + (Z-10)^2)
SHADE_VOLUME, SPHERE, 8, V1, P1
; Render in the Z-graphics buffer
thisDevice = !D.Name
Set_Plot, 'Z'
Device, Set_Resolution=[500,500]
Plot, Findgen(40) ; Don't remove this line! :-)
Erase
; Set !P.T Transformation matrix.
Scale3, XRANGE=[-10,30], YRANGE=[-10,30], ZRANGE=[-10,30]
; Render sphere in red colors.
LoadCT,3, NColors=100
Set_Shading, Values=[0,99]
image = POLYSHADE(V1, P1, /T3D)
; Display the map_projection.
Map_Set, /Cylindrical, /Grid, /Continents, $
/NoErase, /T3D, ZValue=10, /NoBorder, $
Position=[0,0,1,1]
PlotS, [0,1,1,0,0], [0,0,1,1,0], $
[0.5,0.5,0.5,0.5,0.5], /T3D, /Normal
; Take a snapshot of the Z-buffer.
snap = TVRD()
; Trim it up.
snap = snap(50:449, 50:449)
; Display the snapshot on the display.
Set_Plot, thisDevice
Window, XSize=400, YSize=400
TV, snap
END
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|