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

Home » Public Forums » archive » Re: plotting on a sphere
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: plotting on a sphere [message #31408 is a reply to message #31402] Sun, 07 July 2002 15:19 Go to previous messageGo to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
"Chris O'Dell" <odell@cmb.physics.wisc.edu> wrote in message
news:3D260AC8.3050406@cmb.physics.wisc.edu...

> I am new to 3D graphing in IDL. I would like to plot various
> scalar fields on the surface of a sphere, displayed in 3D using
> color contours. Ideally, I would be able to then use my mouse to
> rotate the sphere to different orientations.

If you want 3D with rotations then you want object graphics.

To create a sphere in object graphics, you use MESH_OBJ to create a list of
vertex positions and a connectivity list (i.e. a list specifying which
vertices have to be connected to draw the shape). Then you feed these to an
IDLgrPolygon object. Here's an example that creates & displays a
plain-coloured sphere:

pro sphere_example
compile_opt IDL2
if n_elements(n_lon) eq 0 then n_lon = 20
if n_elements(n_lat) eq 0 then n_lat = 20
mesh_obj, 4, vert, conn, replicate(1, n_lon, n_lat)
help, vert, conn
sphere = obj_new('IDLgrPolygon', DATA=vert, POLY=conn, COLOR=[0,0,255],
STYLE=2)
xobjview, sphere
end

To give the sphere a non-uniform colour you use the IDLgrPolygon's
VERT_COLORS property. You will see that the above example creates a mesh
with 400 vertices. The X, Y & Z positions of the vertices are held in the
columns of a [3,400] floating-point array. The VERT_COLORS array should be a
[3,400] byte array, with the columns corresponding to red, green and blue
respectively. Into this you need to load the color at each vertex, expressed
as a function of the X, Y and Z position at that vertex.

--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: interactive polar blobby plots
Next Topic: Re: Adaptation of surf_track for viewing earthquakes in 3 dimensions

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

Current Time: Wed Oct 08 14:56:04 PDT 2025

Total time taken to generate the page: 0.00408 seconds