TDPACK Examples


Example 1

Example 1 is meant to illustrate the use of the basic TDPACK routines. It includes all of the code necessary to draw the stereo picture above, showing two intersecting surfaces, rendered in different styles, enclosed in a box, with tick marks and labels on selected edges of the box.

On a system on which NCAR Graphics has been installed, you can obtain the code for this example, compile it, and execute it by typing the command "ncargex tdex01". This will create an NCAR Graphics metafile called "tdex01.ncgm".


Example 2

Example 2 is a figure that was used to illustrate a scientific article. The green sphere represents the earth, the red and blue rings elements from a model grid, and the narrow black cone a ray emanating from the center of the earth at a specific latitude and longitude. Note that the values of the internal parameters 'LSU', LSV', and 'LSW' have been changed to move the light source from the position of the eye to a point somewhere off to the left and that the value of the internal parameter 'SHD' has been changed to change the nature of the shading from double-light-source mode to single-light-source mode.

The reason that none of the objects in the figure casts a shadow on any of the others is that the shading algorithm is a simple one that does not use ray-tracing.

On a system on which NCAR Graphics has been installed, you can obtain the code for this example, compile it, and execute it by typing the command "ncargex tdex02". This will create an NCAR Graphics metafile called "tdex02.ncgm".


Example 3

Example 3 is meant to illustrate the use of the simplified-interface routines. It produces the following two frames, of which the first illustrates the use of TDEZ2D and the second illustrates the use of TDEZ3D:

(tdex03, frame 1)

(tdex03, frame 2)

On a system on which NCAR Graphics has been installed, you can obtain the code for this example, compile it, and execute it by typing the command "ncargex tdex03". This will create an NCAR Graphics metafile called "tdex03.ncgm".


Example 4

Example 4 is an elaboration of example 1 meant to illustrate the use of the routine TDCTRI to slice the triangles produced by calls to TDSTRI and TDITRI using a number of "cut planes", each of which is perpendicular to the U, V, or W axis at a specified position along the axis. Once the triangles have been sliced up in this fashion, the user's code can process the triangles in a simple fashion, changing the rendering style for each in such a way as to make the shading of the surface at a given point dependent on the U, V, and W coordinates of the point. In this case, the simple surface is shown in shades ranging from blue at the bottom to red at the top, the isosurface intersecting it is shown in yellow, and the intersections of both surfaces with the planes U=0, V=0, and W=0 are shown in cyan.

This example also shows how to define rendering styles using a set of shades that range from light to dark, depending on the angle between the line of sight and the local normal to the surface. (This might better be done using HSV, rather than RGB, definitions of the colors involved, but, in my view, the RGB scheme works acceptably well.)

On a system on which NCAR Graphics has been installed, you can obtain the code for this example, compile it, and execute it by typing the command "ncargex tdex04". This will create an NCAR Graphics metafile called "tdex04.ncgm".

Note: On some systems, this example may take a rather long time to run. This is because it uses rather high-resolution data arrays. This was done in order to properly render the rather sharp edges of the surface in yellow. The example can easily be modified to use lower-resolution arrays, buy this will cause some degradation in the quality of the image.


Example 5

Example 5 is an elaboration of example 1 meant to show how one can subject the triangles in a triangle list to various transformations. It produces four frames: the first of them is identical to that for example 1 and each of the other three shows a particular transformation of the triangles.

On a system on which NCAR Graphics has been installed, you can obtain the code for this example, compile it, and execute it by typing the command "ncargex tdex05". This will create an NCAR Graphics metafile called "tdex05.ncgm".


Example 6

Example 6 came from a user; it shows how one can generate a triangle list independently of the routines TDSTRI and TDITRI. In this case, the surface to be rendered is defined by functions R(u,v), PHI(u,v), and Z(u,v), where 0 < u,v < 2 pi. The values of R, PHI, and Z are the cylindrical coordinates of points on the surface, which can easily be mapped into the Cartesian coordinates of points on the surface. The triangles representing the surface are generated directly and rendered using rendering styles which vary with the value of the independent variable "u" to give the viewer insight into the role of that variable in defining the surface. The code can easily be modified to show the role of the independent variable "v" in defining the surface or to show the roles of both "u" and "v" at once (just by un-commenting the proper statement to set a variable called "ISRS").

On a system on which NCAR Graphics has been installed, you can obtain the code for this example, compile it, and execute it by typing the command "ncargex tdex06". This will create an NCAR Graphics metafile called "tdex06.ncgm".


Example 7

Example 7 is an extended and modified version of example 1. It is meant to illustrate the use of a new routine called TDTTRI, which was added on 06/21/2001 and makes it possible to place marks along a user-defined trajectory (the blue spiral).

On a system on which NCAR Graphics has been installed, you can obtain the code for this example, compile it, and execute it by typing the command "ncargex tdex07". This will create an NCAR Graphics metafile called "tdex07.ncgm".


Example 8

Example 8 is meant to illustrate the drawing of curves with arrowheads. It includes all of the code necessary to draw the stereo picture above, showing a spiral with arrowheads along it, enclosed in a box, with tick marks and labels on selected edges of the box.

On a system on which NCAR Graphics has been installed, you can obtain the code for this example, compile it, and execute it by typing the command "ncargex tdex08". This will create an NCAR Graphics metafile called "tdex08.ncgm".


C Example 1

C example 1 is meant to illustrate the use of the C interface to the basic TDPACK routines. It includes all of the code necessary to draw the stereo picture above, showing two intersecting surfaces, rendered in different styles, enclosed in a box, with tick marks and labels on selected edges of the box. There are also three marks (in red) and some labels.

On a system on which NCAR Graphics has been installed, you can obtain the code for this example, compile it, and execute it by typing the command "ncargex c_tdex01". This will create an NCAR Graphics metafile called "c_tdex01.ncgm".


TDPACK Demo

The TDPACK demo is a program that allows one to investigate the capabilities of TDPACK in an interactive manner. On a system on which NCAR Graphics has been installed, simply execute the command

  tdpackdemo

This will create an X window containing an initial display of a simple surface. Commands may then be typed in the original window, directing the demo program to change the X-window display in various ways. A little experimentation should suffice to learn what is possible; a good place to start is with an "H" command, which will give you a list of all the possible commands.

The code of the TDPACK demo program may be viewed here.