The Mathematica Journal
Departments
Download This Issue
Home
Feature Articles
Graphics Gallery
Tricks of the Trade
In and Out
Columns
The Mathematica Programmer
New Products
New Publications
Classifieds
Calendar
News Bulletins
Editor's Pick
Mailbox
Letters
Write Us
About the Journal
Staff and Contributors
Submissions
Subscriptions
Advertising
Back Issues

Data Structures

Effective data structures, appropriate to the problem domain, are essential. To begin with, the star is simply a list of [Graphics:../Images/index_gr_46.gif] 3-vectors, each given by an [Graphics:../Images/index_gr_47.gif] coordinate representation. The order of the vectors in the star is not important as it will be treated like a set. For the examples of Figure 3, I chose the following.

[Graphics:../Images/index_gr_48.gif]

In the first case, four vectors in general position were selected (i.e., no three vectors are coplanar, so the result is bounded by parallelograms). In the second case, three vectors lie in a plane, and so the zonohedron contains hexagons in parallel planes.

[Graphics:../Images/index_gr_49.gif]

Figure 4. The parts of an n-zone zonohedron are named with an n-vector of 0's 1's, and -1's. The star for (a) is (c); the star for (b) is (d). Both have four zones, but in (b,d), three zonal directions are coplanar giving a hexagonal face.

We next define a "[Graphics:../Images/index_gr_50.gif]-representation" to represent parts, such as faces, edges, and vertices. Observe that there are three possible positions for a part relative to the [Graphics:../Images/index_gr_51.gif]th zone: the part can be entirely on one side of the [Graphics:../Images/index_gr_52.gif]th zone, entirely on the other side of the zone, or (if not a vertex) it can span the zone. We represent any part with a list of n elements in which the [Graphics:../Images/index_gr_53.gif]th component is respectively 1, [Graphics:../Images/index_gr_54.gif], or 0. Figure 4 illustrates this representation with the examples of Figure 3. The sign of any ±1 is understood in terms of the corresponding element of the star. Observe that a hexagon representation has three zeros as it spans three zones, a parallelogram has two zeros, an edge has one zero, and a vertex representation has zero zeros (i.e., it consists entirely of 1's and [Graphics:../Images/index_gr_55.gif]'s). These are just the Cartesian coordinates in [Graphics:../Images/index_gr_56.gif]-space of the center of the edge-two hypercube component, which is the preimage of the part.

One useful property of this representation is that a part [Graphics:../Images/index_gr_57.gif] is centrally opposite the part [Graphics:../Images/index_gr_58.gif]. For another, notice that a part [Graphics:../Images/index_gr_59.gif] is a subpart of [Graphics:../Images/index_gr_60.gif] iff [Graphics:../Images/index_gr_61.gif] is 0 in all positions where they differ. So, to find the two endpoints of an edge, we replace the 0 in its representation first with 1 and then with -1. There is also a simple method to find the edge opposite a given edge, [Graphics:../Images/index_gr_62.gif], within a given face, [Graphics:../Images/index_gr_63.gif]. We simply negate those components of [Graphics:../Images/index_gr_64.gif], which are zero in [Graphics:../Images/index_gr_65.gif], while keeping the other components unchanged (i.e., compute [Graphics:../Images/index_gr_66.gif]).

Finally, we need a data structure for a complete polyhedron, which can be the input and output of a zonohedrify function, so we can nest it. The format we will use is that a polyhedron is a list of faces, a face is a list of vertices (in a cyclic order around the perimeter), and a vertex is an [Graphics:../Images/index_gr_67.gif] triple. Mathematica provides a package of polyhedra, but in a different form. The built-in function Vertices returns a list of a built-in polyhedron's vertices, in [Graphics:../Images/index_gr_68.gif] form. The built-in function Faces provides a list of its faces, where each face is represented as a list of indices into Vertices. We define a function builtInPoly to convert a built-in polyhedron from that format into our format.

[Graphics:../Images/index_gr_69.gif]

We can easily extract the vertices of a polyhedron in our format.

[Graphics:../Images/index_gr_70.gif]

The following function takes a polyhedron in our format and displays it with Mathematica's 3D graphics. Each face must be headed with Polygon.

[Graphics:../Images/index_gr_71.gif]

For example, to load the Polyhedra package and then convert and display the built-in icosahedron, we type the following.

[Graphics:../Images/index_gr_72.gif]


Converted by Mathematica      September 30, 1999

[Prev Page][Next Page]