**************************************************** PostScript Language Extension in "True 3-D" **************************************************** DIGITAL DAGUERREOTYPES version 1.1 includes a prototype version of a dedicated 3-D coordinate system based upon the PostScript language itself. While "true 3-D" representations of objects in PostScript are not new -- see, e.g., Tony Smith, "The Evolution of a Complex Geometric Logo," in Stephen F. Roth, ed., REAL WORLD POSTSCRIPT: TOOLS AND TECHNIQUES FROM POSTSCRIPT PROFESSIONALS (Addison-Wesley, 1988), ISBN: 0-201-06663-7, pp. 351-373, some of these earlier projects have focused on a single type of object as opposed to a general 3-D transformation system. This documentation is intended to explain some emerging features of Digital Daguerreotypes 3-D support, and to provide some information about the " true 3-D" illustrations included with this release of version 1.1. GENERAL CONCEPTS Digital Daguerreotypes 1.1 includes a 3-D "world coordinate system" -- that is, a coordinate system with x, y, and z axes for mapping and transforming points in 3-D user space. This system is somewhat analogous to the built-in PostScript language coordinate system in two dimensions (x and y axes). Just as the standard 2-D system maps points from 2-D user space to device space, so the 3-D extension maps points from 3-D user space to the standard PostScript 2-D user space, where they are then mapped to device space. Digital Daguerreotypes transformations in 3-D often correspond to standard matrix operations in 2-D PostScript user space: Operation 2-D operator 3-D procedure --------- ------------ ------------- Scaling scale Scale Translation translate Translate Rotation rotate XRotate (x-axis) YRotate (y-axis) ZRotate (z-axis) Shearing concat Concat Perspective ---------- Perspective -1- Just as various standard PostScript 2-D transformations (e.g. scaling and translation) can be combined or concatenated using the concat operator, so the Concat procedure serves this same purpose in the Digital Daguerreotypes 3-D language extension. Note that while 3-D procedures affect the way in which 3-D coordinates are mapped to 2-D user space, it is also possible to adjust the positioning or appearance of a 3-D object by altering the way in which 2-D user space is mapped to device space -- scaling and translation are obvious examples. THE 3-D MATRIX SYSTEM In representing 2-D matrices, the standard PostScript language uses one-dimensional arrays listing the elements row by row. Further, the language implicitly uses a 3x3 homogenous transformation matrix, but explicitly includes only the terms for scaling/rotation/shearing (2x2 submatrix) plus those for translation (2x1 submatrix). Thus [1 0 0 = [1 0 0 1 5 5] 0 1 0 5 5 1] with the final column implicitly fixed at projection terms of 0 and a world-scaling factor of 1. Similarly, in cases of parallel as opposed to perspective projections, Digital Daguerreotypes supports a 12-element matrix of scaling/rotation/shearing (3x3 submatrix) plus translation (3x1 submatrix). Thus [1.5 0 0 0 = [1.5 0 0 0 1.2 0 1 1 1 2 2 4] 0 1.2 0 0 1 1 1 0 2 2 4 1] with the final column implictly assumed to contain three projection terms of 0 and a world scale of 1. However, while the designers of the PostScript language may have reasonably decided that non-zero projection terms might be unnecessary for the 2-D system, they are frequently useful in 3-D for perspective projections. Thus Digital Daguerreotypes also supports a complete 16-element matrix (4x4) including perspective and world scale elements: [1.5 0 0 .001 = [1.5 0 0 .001 0 1.2 0 .001 1 1 1 .002 2 2 4 1] 0 1.2 0 .001 1 1 1 .002 2 2 4 1] -2- To accommodate both 12-element and 16-element forms of the 3-D transformation matrix in a user-friendly way, Digital Daguerreotypes automatically determines the form of a given 3-D matrix and selects the appropriate routine for concatenating matrices of either length (i.e. 12 x 12, 12 x 16, 16 x 12, or 16 x 16). Certain of the included files demonstrate derivative procedures such as rotation around an arbitrary 3-D axis. DRAWING PROCEDURES IN 3-D Version 1.1 illustrations some 3-D path and drawing procedures with obvious parallels to standard 2-D operators, such as 3M (3-D moveto); 3L (3-D lineto); 3RM (3-D rmoveto); and 3RL (3-D rlineto). Some of the sample files show how these simple procedures can be used to develop more complex routines, such as drawing a 3-D polygon or a cube. AN IMPORTANT LIMITATION OF VERSION 1.1 Please note that version 1.1 cannot correctly handle relative path or drawing procedures when a perspective projection (one or more non-zero projection terms) is enabled. Handling this situation will require a mechanism analogous to that of the built-in PostScript 2-D transformation system for inverting a transformation matrix, and thus mapping from device space to current user space. Similarly, the 3-D mechanism would map from "transformed 3-D space" to "3-D user space" -- recording the transformed current point established by a drawing operation, and later converting that point to the 3-D user space system in effect at the time of a subsequent drawing operation -- permitting the addition of a relative moveto (3RM) or relative lineto (3RL) vector, and so forth. Unfortunately, inverting a 4x4 matrix may have nontrivial failure modes depending on round-off error and the like; thus the deferral of this problem to a subsequent version of Digital Daguerreotypes. For the simpler situation of relative path or drawing procedures with a parallel projection in effect (projection terms all zero), version 1.1 uses a simple delta transform for these procedures. -3- USING 2-D PROCEDURES IN A 3-D CONTEXT Various 2-D procedures may be applied to the surfaces of objects defined in 3-D coordinates, including various gradient effects and surface extrusions. One interesting workaround is a technique for introducing 3-D transformations into procedures originally designed for repeated 2-D transformations. For example, QLathe takes four arguments: the number of repetitions; the angle of (regular 2-D) rotation; the 2-D transformation matrix to be applied after each repetition; and the path or drawing procedure to be invoked each time. Thus 10 36 [1 0 0 1 0 0] { DrawBox } QLathe calls for 10 repetitions of the path or drawing procedure; a rotation of 36 degrees after each repetition; transformation each time by the simple 2-D identity matrix (no further change); and invocation of DrawBox as the drawing procedure to be repeated each time. Here we assume that DrawBox is a user-defined procedure. Now consider the following procedure -- assuming that Cube1 is the name of a user-defined routine for drawing a cube: 10 { 36 XRotate 0 } [1 0 0 1 0 -40] { Cube1 } QLathe Here there are 10 repetitions, as before. However, rather than a simple numerical parameter for the rotation, we have a PostScript procedure as the second argument. This procedure first invokes the 3-D command for a rotation of 36 degrees on the x-axis. Then -- critically important -- it places the remaining item 0 on the stack to serve as the argument for the standard 2-D rotate operator included in QLathe. Omitting this 0 would very likely result in some error, typically a typecheck. Note that our 2-D matrix argument translates down 40 units after each repetition -- effectively relocating the 2-D "window" into which 3-D objects are projected. Thus we might see a series of ten cubes moving down the page: 3-D transformations do not affect this 2-D translation process. Similar strategies can incorporate 3-D transformations into other 2-D procedures for repeated invocation of a given path or drawing procedure: for example, gradient extrusions such as VZFill or VZEdge. -4- INTERIOR SURFACE MANAGEMENT (ISM) AND SURFACEFRAME TECHNIQUES Version 1.1 includes a very tentative demonstration of what appears to be an interesting philosophy for representing polyhedra or similar objects: Interior Surface Management or ISM for short. In the case of a cube or other convex polyhedron, some facets have their exterior or outward-facing surfaces turned toward the observer, while others present their interior or inward-facing surfaces. In the case of a cube, for example, from a given point of view there are typically three exterior and three interior facets -- putting aside the case of a facet appearing edge-on. If the object is completely solid and opaque, then only the exterior surfaces will be visible; these surfaces will completely obscure the surfaces of the interior facets. However, if the exterior surfaces have "holes" or "portals," then portions of the interior surfaces may become visible. From an artistic point of view, the combination of exterior and partially revealed interior surfaces offers many expressive possibilities. Thus Digital Daguerreotypes -- primarily an art utility, as opposed to a formal drafting system or a scientific imaging system -- assumes that the user may wish to image both exterior and interior surfaces. Note especially that the interior and exterior surfaces for a given facet may be assigned radically contrasting rendering attributes, as in many of the sample illustrations. Thus the "database" for a cube, for example, defines rendering attributes for 12 surfaces -- an interior and an exterior surface for each of the six facets. In principle, the ISM process requires three steps: (1) Determine which facets are exterior or interior in a given 3-D transformation system. (2) Image the interior facets, if desired. (3) Image the exterior facets, if desired. Choosing not to image interior facets improves efficiency in situations where an object is indeed solid and opaque, since these facets would be completely obscured. Imaging ONLY the interior facets might be useful for testing purposes, or for getting a full and unobstructed view of these facets at some point in the design process. -5- Traditionally, 3-D graphics images have presented either a WIREFRAME representation (both exterior and interior facets represented by edges), or a HIDDEN SURFACE REMOVAL option (only exterior facets visible). In contrast, the ISM approach presents an object as a set of shaded SURFACES, but with a capability of revealing interior surfaces under appropriate conditions -- hence the term SURFACEFRAME for this style of representation. Note that version 1.1 implements ISM only in the restricted, but not uninteresting, case of a cube or block (i.e. a parallelepiped created by scaling a cube arbitrarily along any of the 3-D axes). Further, the algorithm for exterior/interior facet determination is extremely crude: the routine simply determines the "most exposed vertex" (MEV) and classifies the three facets sharing that vertex as exterior, with the others being interior. This crude algorithm appears to work successfully for arbitrary 3-D rotations, but fails under various shearing conditions -- not to speak of the problems raised by perspective. In future releases, ISM might draw upon various depth sort algorithms linked to a viewing transformation system. For the simple case of a convex polyhedron, ISM might function using a standard "back surface/front surface" identification routine -- back faces being synonymous with interior surfaces, and front faces with exterior surfaces. Even when coupled with facet extrusion options, ISM remains a surface or boundary-representation strategy, as opposed to a true volumetric or constructive solid geometry (CSG) method. For many artistic purposes, however, ISM may be an interesting approach. ISM AND "EOCLIP CARVING" The ability to display both interior and exterior surfaces invites some "reverse masking" technique to "carve out" some portion of an exterior surface, revealing portions of inner facets. The "carved" shapes might include polygons, curves, text characters or the like, and so forth. Fortunately, PostScript provides a powerful operator for this purpose, which works with 3-D as well as 2-D paths: eoclip. By first defining a clipping path, and then defining a second path with eoclip, we effectively apply a reverse mask to the second path, so that only the remaining portion of the first path will be affected by a painting operation. This effect may be seen in certain 3-D illustration files included with version 1.1, such as EOCARVE.EPD and MODELT.EPD. -6- Note that applying this "reverse masking" or "carving" effect to objects including curves, as opposed to polylines, may in some situations provoke PostScript errors on at least some devices. In short, this special application of eoclip can be useful for "carving" a transparent "portal" out of a 3-D surface: for example, in order to reveal interior facets of a polyhedron. "TEXT CHARACTERS" IN 3-D: INTRODUCING GLYPHS While PostScript Type 1 and Type 3 fonts can support a vast range of "3-D" effects, including text extrusion and quasi-perspective effects supported by Digital Daguerreotypes and many other applications, these fonts understandably are based on a 2-D coordinate system. Thus the process of generating "true 3-D" text representations -- that is, "characters" supporting arbitrary 3-D rotations and other transformations -- appears to call for solutions other than those offered by the PostScript font machinery. Digital Daguerreotypes 1.1 offers a very tentative demonstration of one possible solution: the creation of user-defined text characters or GLYPHS which draw upon 3-D procedures, and thus are open to the full range of 3-D transformations. The simplest and likely most typical case would be that of a PLANAR GLYPH: a text character set on a given plane in the 3-D coordinate system. For simplicity's sake, we might place the glyph in the xy, xz, or yz plane -- with the option, of course, to transform the glyph to any desired plane by arbitrary rotation. Such a glyph, rather like a PostScript font, would typically be an outline definition specified in two dimensions: a horizontal dimension along with the text stream moves, and a corresponding vertical dimension. This outline, like that of a PostScript outline font, could naturally be painted in many different ways: as a filled path, stroked path, simple extruded gradient, "neon" outline, and so forth. In contrast, a NONPLANAR GLYPH would define a character outline in terms of three dimensions: horizontal, vertical, and "depth." Yet more ambitious is the concept of a SUPERGLYPH: a nonplanar glyph defining a character outline as a set of several surfaces, perhaps with built-in painting routines for each surface, or even some facility for specifying user-defined painting routines at the time the glyph is called. Such a multi-surface "superglyph" might use interior surface management routines much like a usual polyhedron. -7- The artwork files SUNDIAL4.EPD, TCUBE1.EPD, TCUBE2.EPD, TCUBE3.EPD, and MODELT.EPD demonstrate a simple planar glyph for the "T" character. Incidentally, there is no reason that one might not create "quasi-3D supercharacters" in a PostScript Type 3 font, including multiple "surfaces" and various customized painting routines; the distinguishing feature of "true 3-D" glyphs is suppport for 3-D transformations. PLOTTING IN 3-D: FUNCTIONS OF TWO VARIABLES While Digital Daguerreotypes is not a symbolic mathematics application or graphing package, some of the sample files demonstrate how version 1.1 can be used to create shaded surface plots of two-variable functions, e.g. z = cos x sin y The ProtoGraph procedure demonstrated in GRAPH1.EPD, GRAPH2.EPD, MONKEY.EPD, ANTHONY.EPD, and ANTHONY2.EPD generates a surface plot with user-defined shading procedures applied to quadrilateral regions. Note that while the z-axis is typically the depth axis for most 3-D illustrations, in graphing it is more conventionally the vertical axis. The SetAxes command is available to orient the three axes however desired. Although graphs with a vertical z-axis for functions of two variables (x and y) are standard, an interesting variant might be termed a "billow graph" with z as the depth axis, where the surface appears to "billow" toward the viewer for positive values of z, say, and to billow away from the observer for negative values. This effect may be seen in GRAPH1.EPD. REMAINING PROBLEMS AND POSSIBILITIES Obviously version 1.1 only begins to touch upon the many possibilities of true 3-D modelling based upon the PostScript language. Future developments might obviously include a viewing transformation system (eye coordinates as well as world coordinates); extension of interior surface management to routines for various polyhedra, and eventually to a general depth sort algorithm for multiple objects. The "glyph" concept might evolve into some kind of 3-D equivalent for PostScript Type 3 fonts, including the use of string objects to index arrays of 3-D character procedures, and a mechanism for 3-D transformations affecting only glyph characters, analogous to the makefont operator. -8- Again, my intention in this version 1.1 is merely to adumbrate some of the applications and artistic possibilties for a dedicated 3-D design system based on the PostScript language. "TRUE 3-D" ARTWORK FILES IN VERSION 1.1 The following is a brief summary of artwork (.EPD) files included with Digital Daguerreotypes 1.1 which illustrate the dedicated 3-D world coordinate system added to this version. SPIRACAL.EPD This file is an early example of 3-D rotation along the y-axis; the title is short for SPIRA CALAMI, or "Spiral of Calamus," a name referring to the legendary Greek musician Calamus (a rustic player of reed pipes), and the "spiral" of reed or organ pipes suggested by the design. OPENCITY.EPD STEPUP.EPD These illustrations grew out of an experiment with three-point perspective. The earlier OPENCITY.EPD shows a single open box in an "aerial" three-point perspective, while STEPUP.EPD shows a series of such boxes with shearing and rotation -- the latter suggesting to me possibly an observer "floating about" in zero gravity, or more precisely, microgravity. These examples suggested to me the power of revealing interior surfaces. For the example which inspired these designs, see Peter C. Gasson, GEOMETRY OF SPATIAL FORMS (Chichester, UK: Ellis Harwood Ltd, 1983), ISBN 0-85312-620-8, Figure 11.9 and explanation at pp. 527 and 528. CUBEISM1.EPD CUBEISM2.EPD CUBEISM3.EPD CUBEISM4.EPD CUBEISM5.EPD These samples demonstrate interior surface management with a cubelike object undergoing 3-D rotations. I found it artistically interesting to assign simple gray fills to the exterior surfaces, but "colorful" grayscale gradients to the interior surfaces. SUNDIAL4.EPD This illumination takes a 3-D "T" glyph and rotates it in the y-axis to generate a helical construct. While one could interpret this resulting object as simply a surface of revolution, I tend to view it rather as a "spacetime diagram" with the y-axis signifying time in a 4-D system. Hence the full name SUNDIAL 4-D: IN HOC ANNI CIRCULUM ("In this circle of the year"), the Latin being the opening phrase of a medieval carol. Looking at it, I have almost the feeling of looking at the cycle of time from a place outside time. I dedicate this illumination to my friend M.C. whom I met in San Francisco, an artist of many dimensions. -9- TCUBE1.EPD TCUBE2.EPD TCUBE3.EPD These files illustrate interior surface management of a cubelike polyhedron in conjunction with "carving" of "portals" into facets using the eoclip operator. Specifically, the "T" glyph serves as path for such carving -- hence the name. MODELT.EPD This file shows one view of an "open box" with an extruded facet including a likewise extruded "portal" defined by the "T" glyph outline. While this is not, of course, a true volumetric rendering, it gives the visual effect of "subtracting" one solid region from another. EOCARVE.EPD Here we have a demonstration of arbitrary rotation of a box with "eoclip carving" by polygon shapes. While this illustration was meant merely to show a rotation around a full 360 degrees in 30 degree steps (actually 420 degrees, since the last three images repeat the first three), my friend D.G. of Canada interpreted the page to represent three boxes in free fall -- each vertical column being a time series of one box. GRAPH1.EPD GRAPH2.EPD These two files plot shaded 3-D surfaces based on the trigonometric function of two variables z = cos x sin y with GRAPH1.EPD presenting a "billow graph" (z-axis in depth direction), and GRAPH2.EPD presenting a more conventional graph with the z-axis in the vertical direction. For GRAPH2.EPD, the variant form of the basic function is z = cos (x pi) sin (y pi) thus effectively magnifying the vertical scale of the graph for dramatic effect. MONKEY.EPD This example plots the "monkey saddle" function 1/3 X^3 -XY^2 whose graph might suggest a saddle accommodating the tail as well as the legs of a monkey. While I decided on a shaded rendering, a rendering procedure simply outlining the quadrilaterals in black after filling them with opaque white might be equally effective: { .2 0 1 Infill } The first parameter sets a linewidth of .2, while a setting of .4 would mean lines twice as thick -- feel free to experiment. -10- ANTHONY.EPD ANTHONY2.EPD These files, named in honor of the mathematician Anthony Barcellos, plot the graph of the picturesque function sin^2 ( (x^2 + y^2)^.5 pi) with two different increments of quadrilateral mapping. With a 3-D graph, an increment twice as fine for both x and y values generates four times as many quadrilaterals over the same range -- and the viewer must decide what increment is most pleasant or aesthetically effective. -M. P. S. 24 September 1992