The 3-D PyGist graphics keeps an internal list called _draw3_list containing complete information about the currently active frame (which may or may not be visible depending on whether draw3 has been invoked). Regular users should never need to access this list; however, there is an access function available called get_draw3_list_ which code developers and maintainers may use to get at the list; get_draw3_n_ returns the number of elements in the viewing and lighting portion of the list, described below. Likewise, ordinary users do not really need to know the structure of this list in detail; however, every user of the 3-D graphics should be aware of the contents of the list, how it affects the graph, and what functions to use to alter it.

_draw3_list is a Python list, organized as follows:

- [rotation, origin, camera_dist, ambient, diffuse, specular, spower, sdir, fnc
_{1}, args_{1}, fnc_{2}, args_{2},...]The elements of this list are divided into the

*viewing*transformation,*lighting*specifications, and*display*information, as follows:

**rotation**: a 3-by-3 rotation matrix giving the angles of view.**origin**: a 3-vector giving the coordinates of the origin in the user's coordinate system.**camera_dist**: A real number giving the camera distance; the value None (the default) translates to infinity.

**ambient**: a light level (in arbitrary units) that is added to every part of the surface regardless of its orientation. It might be said to be the amount of light which a surface exudes on its own. A surface with ambient of 0 is totally black unless illuminated.**diffuse**: a light level which is proportional to cos(theta), where theta is the angle between the surface normal and the viewing direction, so that surfaces directly facing the viewer are bright, while surfaces viewed edge on are unlit (and surfaces facing away, if drawn, are shaded as if they faced the viewer).**specular**: a light level proportional to a high power**spower**of 1 + cos (alpha), where alpha is the angle between the specular reflection angle and the viewing direction. The light source for the calculation of alpha lies in the direction**sdir**(a 3 element vector) in the viewer's coordinate system at infinite distance. You can have ns light sources by making specular, spower, and sdir (or any combination) be vectors of length ns (3-by-ns in the case of sdir).

- fnc
_{1}, fnc_{2}, etc.: Plotting function(s) (whose argument lists are arg_{1}, arg_{2}, etc., respectively) defining the component(s) of this graph. During its normal operating mode, the 3-D graphics accumulates information about calls to plotting functions until the user calls the function draw3. These calls are then executed when draw3 is invoked.

- orient3 (phi = angle
_{1}, theta = angle_{2}) - rot3 (xa = angle
_{x}, ya = angle_{y}, za = angle_{z})

Note that most of the functions in 3-D PyGist accept keyword arguments. These arguments may be entered in any order; omitted arguments will default to a sensible value.

orient3 sets the orientation of the object to (angle_{1}, angle_{2}). Orientations are a subset of the possible rotation matrices in which the z axis of the object appears vertical on the screen (that is, the object z axis projects onto the viewer y axis). The theta angle is the angle from the viewer y axis to the object z axis, positive if the object z axis is tilted towards you (toward viewer +z). phi is zero when the object x axis coincides with the viewer x axis. If neither phi nor theta is specified, phi defaults to - pi / 4 and theta defaults to pi / 6. If only phi is specified, theta remains unchanged, unless the current theta is near pi / 2, in which case theta returns to pi / 6, or unless the current orientation does not have a vertical z axis, in which case theta returns to its default. If only theta is specified, phi retains its current value. Unlike rot3, orient3 is not a cumulative operation.

rot3 rotates the current 3D plot by angle_{x} about viewer's x axis, angle_{y} about viewer's y axis, and angle_{z} about viewer's z-axis.

- mov3 (xa = val
_{1}, ya = val_{2}, za = val_{3}) - aim3 (xa = val
_{1}, ya = val_{2}, za = val_{3}) - setz3 (zc = dist)

mov3 moves the current 3D plot by val_{1} along the viewer's x axis, val_{2} along the viewer's y axis, and val_{3} along the viewer's z axis. aim3 moves the current 3D plot to put the point (val_{1}, val_{2}, val_{3}) in object coordinates at the point (0, 0, 0) -- the aim point -- in the viewer's coordinates. In both functions, if any of the val_{1}, val_{2}, or val_{3} is missing, it defaults to 0.

setz3 sets the camera position to dist (x = y = 0) in the viewer's coordinate system. If dist is None or if zc is missing, set the camera to infinity (default).

Our examples are postponed until later in the chapter, when we have covered enough material to give complete sequences of computations and PyGraph function calls, and show the resulting plots.

- light3 (ambient=a_level, diffuse=d_level, specular=s_level,
- spower=n, sdir=xyz)
This function is used to set the lighting parameters for the current drawing list.

- <plot function> (arg
_{1}, arg_{2}, arg_{3}, ...) - clear3 ( )
When one of the plotting functions (plwf, pl3surf, pl3tree) is called and the internal variable _draw3 has been set to zero, or else if it is nonzero and the idler is a do-nothing routine, Then this plot call will add <plot function> to the display list, and will process the arguments into a Python list, which will be added to the display list after the function name.

The function clear3 clears the display list of all plotting functions. It leaves orientation and lighting information unchanged.

[Top] [Prev] [Next] [Bottom]

support@icf.llnl.gov