Looking for a powerful visualization tool? Geomview, designed to serve as both a general purpose viewer and a visualization tool for mathematics research, may fit the bill. Tim Jones demonstrates Geomview's virtually unlimited applications.

The machinery of Geomview is contained within the Object Oriented Graphics Library (OOGL) which was also developed by the Geometry Center at the University of Minnesota. All of the scenes that are displayed by Geomview are described in terms of OOGL objects. For example, a sphere in Geomview can be described in terms of the OOGL object called SPHERE. The type of object, as well as the physical description, can be passed to Geomview in an OOGL object file which, in the case of a simple sphere, would contain the following text:

SPHERE       # name of the OOGL object
1.0          # radius of the sphere
0 0 0        # x,y,z coordinate of the center

If you open this file from within Geomview, a unit sphere will appear in the camera widget.

OOGL object files can also be composed of multiple OOGL objects. For example, a file describing a triangle slicing through the center of the above sphere would look like:

LIST            # More than 1 OOGL object
{               # Separates the Objects
SPHERE          # A OOGL Object
1.0             # Radius
0 0 0           # Center, x, y, z
{ OFF           # Format for describing polyhedra
3 1 3           # Number of vertices, faces, edges
-2.0  2.0  0.0  # vertex 0
 4.0  0.0  0.0  # vertex 1
-2.0 -2.0  0.0  # vertex 2
3 0 1 2         # number of vertices, and order to
                # connect them

OOGL appears to be fairly complete in the sense that you can describe a variety of objects and their attributes within the context of the library. Other OOGL objects include meshes, Bezier surfaces, lines, and quadrilaterals. Each of these objects has appearance attributes such as surface color, surface reflectance properties, and edge colors that can be specified either from Geomview menus or within the OOGL object files. However, the Linux port (like several others) does not yet support transparency attributes.

The Graphical Command Language

One of the powerful features of Geomview is its graphical command language (GCL), which is rich enough to allow users to not only manipulate the displayed scene, but to change the appearance attributes and animate objects in it. These commands can be either typed directly into Geomview via a command widget or piped from an external program. To illustrate just how easy this is, consider the following example: Say you want to animate a pendulum in the viewer. You will first need to describe the pendulum in terms of OOGL objects and then swing the pendulum by rotating it about an axis that passes through the end of the string from which the bob hangs.

A simple pendulum can be described as two objects, a line for the string and a sphere for the bob. Or, in terms of a list object file which I call pendulum.list:

LIST            # More than 1 OOGL object
SPHERE          # A OOGL Object
1.0             # radius of the sphere
0.0 0.0 -5.0    # center of the sphere
VECT            # A vector object
1 2 1           # lines, vertices, colors
2               # vertices in each line
1               # colors in each line
0.0 0.0 0.0     # vertex 0
0.0 0.0 -4.0    # vertex 1
1.0 0.0 0.0 1.0 # color of line
                # (red, green, blue, alpha)

The VECT object describes the string of the pendulum which goes from the origin (vertex 0) to the top of the sphere (vertex 1). The last line describes the color of the string.

For illustrative purposes, I will also put a square 8 units long above the pendulum. This is described in terms of the quadrilateral object (QUAD) which I place in a file called ceiling.quad.

CQUAD   # QUAD object with color
# vertex descriptions are
# (x, y, z, red, green, blue, alpha)
-4.0 -4.0 0.0  0.0 0.0 1.0 1.0  # vertex 0
 4.0 -4.0 0.0  0.0 0.0 1.0 1.0  # vertex 1
 4.0  4.0 0.0  0.0 0.0 1.0 1.0  # vertex 2
-4.0  4.0 0.0  0.0 0.0 1.0 1.0  # vertex 3

The prefix C in front of QUAD indicates that the vertex colors are included next to the location of the vertices. That is, the first three numbers on each line describe a vertex of the ceiling, and the last four give the color and the reflection coefficient. All colors are expressed in terms of fractions of red, green, and blue and are usually followed by a reflection coefficient, which is ignored for the Linux port.

To animate the pendulum, a small C program is used to send GCL commands along a pipe connected between Geomview and the program's standard input and output. These commands tell Geomview to not only load the objects into the viewer, but also to rotate the pendulum about the x axis between -30 and +30 degrees in 1 degree increments.

#include <stdio.h>
  int i,j;
  /* Select no normalization */
  printf("(normalization g0 none)\n");
  /* No bounding boxes */
  printf("(bbox-draw g0 no)\n");
  /* A 8X8 Plane */
  printf("(load ceiling.quad)\n");
  /* A sphere with a string */
  printf("(load pendulum.list)\n");
  /* Flush pipe to Geomview */
  /* Swing to +30 degrees */
  for (i = 0; i < 30; i++)
    printf("(transform \"pendulum.list\""
           "g0 focus rotate 0.017 0.0 0.0)\n");
  /* Swing to -30 degrees */
  for (i = 0; i < 60; i++)
    printf("(transform \"pendulum.list\""
           "g0 focus rotate -0.017 0.0 0.0)\n");
  /* Swing back to 0 */
  for (i = 0; i < 30; i++)
    printf("(transform \"pendulum.list\""
           "g0 focus rotate 0.017 0.0 0.0)\n");
    /* Flush pipe to Geomview */

To see the results, compile the program with gcc pendulum.c. Next, start Geomview from this same directory and access the inspect menu and select commands. The command widget will pop up and you need to type (emodule-define pend a.out) to instruct Geomview to load the executable a.out as an external module named pend. If everything is working right, the module pend should appear in the external modules list and can be activated by clicking on the word pend. The pendulum and ceiling will appear in the camera widget and the pendulum will swing back and forth. You will have to use Geomview's tools to rotate the scene to the view shown in Figure 3.

The loading of the OOGL object files and animation of the above example is accomplished in just a few lines of C code and a total of 4 GCL commands. The first two GCL commands describe some characteristics of the “World” (g0) object which, in turn, are adopted by all objects that are loaded following these commands. By default, when an object is loaded into Geomview, the coordinates of the object are normalized so that the object fits within a unit sphere centered on the origin. The (normalization g0 none) command turns this option off. The second command tells Geomview not to draw black bounding boxes around each object that it loads. The third command, (load filename), tells Geomview to load the OOGL object file filename.

Most of the work is actually done by the fourth and final GCL command. transform tells Geomview to rotate the object pendulum.list by 0.017 radians (about 1 degree) around the x axis and 0 radians about the y and z axes. The other two arguments to transform, g0 and focus, specify that rotations are with respect to the center of the World object (g0) and are to be applied in the frame of reference of the camera. There are many other GCL commands described in the manual that can be used to animate and manipulate OOGL objects.

Although the examples illustrated here have been rather simple, it should be apparent that Geomview is a package with numerous applications. Geomview, in combination with powerful graphical user interface development tools, such as Tcl and Wish, can be used to create interactive 3-D applications in relatively short amounts of time. This is quite a powerful package that should not be ignored by anyone developing applications involving 3-D images or anyone needing an easy-to-use viewer to better visualize objects, whether he is viewing complex mathematical output from Mathematica or simple geometric relationships between lines and planes.


Free Dummies Books
Continuous Engineering


  • What continuous engineering is
  • How to continuously improve complex product designs
  • How to anticipate and respond to markets and clients
  • How to get the most out of your engineering resources

Get your free book now

Sponsored by IBM

Free Dummies Books
Service Virtualization

Learn to:

  • Define service virtualization
  • Select the most beneficial services to virtualize
  • Improve your traditional approach to testing
  • Deliver higher-quality software faster

Get your free book now

Sponsored by IBM