Sketch
Sketch
Sketch
Simple 3D sketching
Version 0.3 (build 7), Friday, February 24, 2012
Gene Ressler
Copyright c 2005 to 2012 Eugene K. Ressler.
This manual is for sketch, version 0.3 (build 7), Friday, February 24, 2012, a program that
converts descriptions of simple three-dimensional scenes into line drawings. This version
generates PSTricks or PGF/TikZ code suitable for use with the TEX document processing
system.
Sketch is free software. You can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version
3, or (at your option) any later version.
Sketch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PAR-
TICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with sketch;
see the file COPYING.txt. If not, see http://www.gnu.org/copyleft.
i
Table of Contents
1 About sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Reporting bugs and recommending improvements. . . . . . . . . . . . . . . 1
1.2 Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Introduction by example . . . . . . . . . . . . . . . . . . . . . . . 2
2.1 Hello world . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3 Drawing a solid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.4 Special objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.5 Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.6 Repeated objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.7 Swept objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.7.1 Point sweeps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.7.2 Polyline sweeps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.7.3 Nested sweeps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.7.4 Polygon sweeps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.7.5 Polyline sweeps with closure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.7.6 Affine arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.7.7 More to learn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3 Input language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.1 Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.2 Key and reserved words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.3 Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.3.1 Scalar literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.3.2 Point and vector literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.1.3.3 Transform literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.1.4 Arithmetic expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.1.4.1 Two-operand (binary) forms and precedence . . . . . . . . . 13
3.1.4.2 Unary forms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.1.5 Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.1.5.1 PSTricks options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.1.5.2 TikZ/PGF options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.1.5.3 Dots in TikZ/PGF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.1.5.4 TikZ/PGF user-defined styles . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.1.5.5 Transparency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.1.5.6 Internal options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.6 Point lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2 Drawables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2.1 Dots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2.2 Lines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
ii
3.2.3 Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2.4 Polygons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2.5 Specials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2.6 Sweeps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2.6.1 Swept points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.2.6.2 Swept lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.2.6.3 Swept polygons. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2.6.4 Swept blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2.6.5 Sweep face splitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2.7 Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.2.8 Repeats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.2.9 Puts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3.1 Forms of definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3.2 Forms of references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.4 Global environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.4.1 Global options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.4.2 Camera . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.4.3 Picture box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.4.4 Frame. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.4.5 Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4 Building a drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2 A technical drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.3 A hierarchical model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.4 Caveats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.4.1 Limits on sketch error detection . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.4.2 Clipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.4.3 Hidden surface removal and polygon splitting . . . . . . . . . . . . . 35
4.4.3.1 Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.4.3.2 Bugs and anomalies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5 Command line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Index of syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Index of concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Chapter 1: About sketch 1
1 About sketch
Sketch is a small, simple system for producing line drawings of two- or three-dimensional
objects and scenes. It began as a way to make illustrations for a textbook after we could find
no suitable tool for this purpose. Existing scene processors emphasized GUIs and/or photo-
realism, both un-useful to us. We wanted to produce finely wrought, mathematically-based
illustrations with no extraneous detail.
Sketch accepts a tiny scene description language and generates PSTricks or TikZ/PGF
code for LATEX. The sketch language is similar to PSTricks, making it easy to learn for
current PSTricks users. See www.pstricks.de for information on PSTricks. TikZ/PGF is
similar. See http://sourceforge.net/projects/pgf. One can easily include arbitrary
PSTricks or TikZ/PGF drawings and text over, in, or under sketch drawings, providing
access to the full power of LATEX text and mathematics formatting in a three-dimensional
setting.
1.2 Contributions
If you intend to implement an enhancement of your own, that’s terrific! Consider collabo-
rating with us first to see if we’re already working on your idea or if we can use your work
in the official release.
Chapter 2: Introduction by example 2
2 Introduction by example
The sketch input language will seem familiar to users of the PSTricks package for LATEX.
The following program draws a triangular polygon pierced by a line.
polygon(0,0,1)(1,0,0)(0,1,0)
line(-1,-1,-1)(2,2,2)
The coordinate system is a standard right-handed Cartesian one.
y
z x
1
Or for European users of A4 size paper, ‘-Te’.
Chapter 2: Introduction by example 3
It is important to know that only the “outside” of a polygon is normally drawn. The
outside is where the vertices given in the polygon command appear in counter-clockwise
order. Thus, if the command above had been
polygon(0,1,0)(1,0,0)(0,0,1)
the polygon would not appear in the picture at all. It would have been culled from the
scene. This culling behavior may seem strange, but stay tuned.
2.2 Options
Many PSTricks and TikZ/PGF options work just fine in sketch. If generating PSTricks,
the code
polygon[fillcolor=lightgray,linewidth=3pt](0,0,1)(1,0,0)(0,1,0)
line[linestyle=dotted](-1,-1,-1)(2,2,2)
produces
polygon(p1)(p4)(p2) % bottom
polygon(p1)(p3)(p4) % left
polygon(p3)(p2)(p4) % rear
If we look inside the TEX file produced by sketch, there will be only three polygons. The
fourth has been culled because it is a “back face” of the tetrahedron, invisible to our view.
It is unnecessary, and so it is removed.
In some drawings, polygons act as zero-thickness solid surfaces with both sides visible
rather than as the faces of solid objects, where back faces can be culled. For zero-thickness
solids, culling is a problem. One solution is to use a pair of sketch polygons for each
zero-thickness face, identical except with opposite vertex orders. This is unwieldy and
expensive. A better way is to set the sketch internal option cull to false in the usual
PSTricks manner.
polygon[cull=false](p1)(p2)(p3)
The following shows the same helix shape drawn first with cull=true (the default) and
then cull=false.
We’ll soon see how to produce these helixes with a few lines of sketch language code.
It may be tempting to turn culling off gratuitously so that vertex order can be ignored.
This is not a good idea because output file size and TEX and Postscript processing time
Chapter 2: Introduction by example 5
both depend on the number of output polygons. Culling usually improves performance
by a factor of two. On the other hand, globally setting cull=false is reasonable while
debugging. See Section 3.4.1 [Global options], page 23 and Section 4.4.1 [Limits on error
detection], page 34.
P3
P1
P2
P4
There are several details to note here. First, the quoting convention for the raw code
is similar to the LATEX \verb command. The first non-white space character following
special is understood to be the quote character, in this case ‘|’. The raw text continues
until this character recurs.
Second, the argument references #1, #2, #3, and #4 refer to point, vector, or scalar
values in the list that follow. This is similar to TEX macro syntax. The transformed and
two-dimensional projections of these three-dimensional points are substituted in the final
output. An argument reference of the form #1-2 is replaced with the angle in degrees of the
two-dimensional vector that connects the projections of the two respective argument points,
here #1 and #2. The substituted angle is enclosed in curly braces { }. When TikZ/PGF
output is being generated, the angle is rounded to the nearest degree because non-integer
angles are not allowed by TikZ/PGF primitives.
As of Version 0.3 of sketch, special arguments may be scalars or vectors in addition
to points. References to scalar arguments are merely replaced with a number formatted
just as any point coordinate. References to vectors become two-dimensional points. The
tick operator that selects individual components of points and vectors elsewhere in sketch
(see for example Section 2.7.6 [Affine arithmetic], page 9) can also be applied to point and
vector argument references. All three dimensions of a transformed point or vector can also
be substitued with ’3. See Section 3.2.5 [Specials], page 18 for details.
By default, special objects are printed last, overlaying all other objects in the scene.
If you specify the internal option lay=in, the hidden surface algorithm considers the entire
special object to be the first point (#1) in the argument list. If that point is behind (of
smaller z-component than) any drawable, then the entire special object is drawn before
Chapter 2: Introduction by example 6
that drawable, so the drawable obscures parts of the special object that overlaps it. In our
example, p1 is the front-most point in the scene (has the largest z-component), so adding
lay=in has no effect.
With option lay=under, a special is drawn before, hence appears under any of the objects
handled by the hidden surface algorithm. This is how the light gray axes were added to the
“hello world” example Section 2.1 [Hello world], page 2.
Special objects are powerful, with many possible uses.
2.5 Transforms
Now let’s add a second copy of the pierced tetrahedron. We’ll rotate the copy 90 degrees
about the x-axis with the origin as center of rotation so we can see the back, then translate
it to the right—in the positive x-direction—so it doesn’t collide with the original. To help
us see what’s going on, make the back side gray.
def pierced_tetrahedron {
def p1 (0,0,1) def p2 (1,0,0)
def p3 (0,1,0) def p4 (-.3,-.5,-.8)
polygon(p1)(p2)(p3) % original
polygon(p1)(p4)(p2) % bottom
polygon(p1)(p3)(p4) % left
polygon[fillcolor=lightgray](p3)(p2)(p4) % rear
line[linecolor=red](-1,-1,-1)(2,2,2)
}
{pierced_tetrahedron} % tetrahedron in original position
put { rotate(90, (0,0,0), [1,0,0]) % copy in new position
then translate([2.5,0,0]) } {pierced_tetrahedron}
Here the entire code of the previous example has been wrapped in a definition by forming a
block with braces (a single item would not need them). The point definitions nested inside
the braces are lexically scoped. Their meaning extends only to the end of the block. The
outer def is called a drawable definition because it describes something that can be drawn.
A drawable definition by itself causes nothing to happen until its name is referenced.
Drawable references must be enclosed in curly braces, e.g. {foo}, with no intervening white
space. In the code above, the first reference {pierced_tetrahedron} is a plain one. Its
effect is merely to duplicate the earlier drawing. Almost any series of sketch commands
stuff may be replaced with def foo { stuff } {foo} without changing its meaning.
The put command supplies a second reference, this time with a transform applied first.
The rotate transform turns the tetrahedron 90 degrees about the origin. The axis of
rotation is the vector [1, 0, 0]. By the right hand rule, this causes the top of the tetrahedron
to rotate toward the viewer and the bottom away. The rule receives its name from the
following definition:
Right hand rule. If the right hand is wrapped around any axis with the thumb
pointing in the axis direction, then the fingers curl in the direction of positive
rotation about that axis.
The translate transform moves the pyramid laterally to the right by adding the vector
[2.5, 0, 0] to each vertex coordinate. The result is shown here.
Chapter 2: Introduction by example 7
This is the first example we have seen of sketch arithmetic. The expression
180 / n_segs causes the eight rotations to add to 180. If you’re paying attention, you’ll
have already noted that there are nine points, producing eight line segments.
You can cause the swept point to generate a single polygon rather than a polyline by
using the closure tag <> after the number of swept objects. Code and result follow
Chapter 2: Introduction by example 8
def n_segs 8
sweep { n_segs<>, rotate(180 / n_segs, (0,0,0), [0,0,1]) } (1,0,0)
z
This example also shows that the swept object may itself be another sweep. In fact, it
may be any sketch expression that results in a list of one or more points or, alternately,
a list of one or more polylines and polygons. The latter kind of list can be created with a
{ }-enclosed block, perhaps following a put or repeat.
Chapter 2: Introduction by example 9
The options of the swept line, if any, are applied to the faces produced by sweeping the
line, but not the end polygons. Otherwise, the sweep options are applied throughout. The
def in this example is an option definition. References to options must be enclosed in
square brackets, e.g. [foo]. You can concatenate several sets of options with a single
reference, e.g. [color, size, style] would cause the option definitions for color, size,
and style to appear in sequence in the output created by the sketch command containing
the reference. Happily, the syntax of sketch is such that options references can never be
confused with vector references. While not apparent in this example, options references are
useful when defining many objects with a similar appearance.
line[arrows=*->](n1)(n2)
The first line computes the cross product of two edge vectors of the triangle and scales it to
unit length. The second computes the average of the vertices. Note that subtraction and
addition of the origin effectively convert vectors to points and vice versa. The line command
draws the normal at the correct spot.
Two caveats regarding this example remain. First, the only way to use PSTricks-style
arrows is with arrows=. The alternative syntax for PSTricks arrows is not allowed in
sketch. Second, you might like to eliminate the third def and write instead the following.
line[arrows=*->](n1) (n1)+[N]
This is not allowed. The point lists in drawables may consist only of explicit points or point
references. You may, however, use arithmetic to calculate point components. The following
works, though it’s a little cumbersome.
line[arrows=*->](n1)((n1)’x+(N)’x, (n1)’y+(N)’y, (n1)’z+(N)’z)
Obviously, the tick operator ‘’x’ extracts components of points and vectors.
3 Input language
This chapter describes the sketch input language in detail.
3.1 Basics
Sketch input is plain ASCII text, usually stored in an input file. It describes a scene, so the
sketch language is a scene description language. Sketch input is also declarative. It merely
declares what the scene ought to look like when drawing is complete and says very little
about how sketch should do its work. Sketch commands are not executed sequentially as
in the usual programming language. They merely contribute to that declaration.
A few syntactic details are important. Case is significant in the sketch language. With
a few exceptions, white space is not. This includes line breaks. Comments begin with % or
# and extend to the end of the line. You can disable a chunk of syntactically correct sketch
code by enclosing it in a def. There is a simple “include file” mechanism. The command
input{otherfile.sk}
causes the contents of ‘otherfile.sk’ to be inserted as though they were part of the current
file.
3.1.1 Identifiers
Identifiers in sketch are references to earlier-defined options, scalars, points, vectors, trans-
forms, drawables, and tags. Definitions are explained in Section 3.3 [Definitions], page 21.
An identifier consists of a leading letter followed by letters, numbers and underscores.
The last character may not be an underscore. Keywords cannot be used as identifiers, and
reserved words ought to be avoided. See Section 3.1.2 [Key and reserved words], page 11.
3.1.3 Literals
Literals in sketch include scalars, points, vectors, and transforms. Literals, along with
defined object references, are used in arithmetic expressions. See Section 3.1.4 [Arithmetic],
page 13.
The project constructor is not generally useful because it defeats hidden surface removal
by collapsing the scene onto a single plane. It is a special purpose transform for drawing
pictures of scenes where three-dimensional objects are being projected onto planes. See, for
example, Section 4.1 [Overview], page 25.
The direct transform constructor allows direct entry of a 4x4 transformation matrix.
Most 3d graphics systems, including sketch, use 4-dimensional homogeneous coordinates
internally. These are transformed by multiplication with 4x4 matrices. The built-in con-
structors (rotate, scale, etc.) are all translated internally to such 4x4 matrices. For more
information on homogeneous coordinate transformations, see any good computer graphics
textbook. The direct transform feature of sketch allows you to enter a matrix of your own
choice. There are not many cases where this is useful, but if you do need it, you need it
badly!
Op Precedence
’ highest (most tightly binding)
^
- (unary negation)
*./
+-
then lowest (least tightly binding)
All operations are left-associative except for ‘^’. Parentheses ‘( )’ are used for grouping to
override precedence in the usual way.
As you can see, the dot operator ‘.’ is usually a synonym for run-of-the-mill multiplica-
tion, ‘*’. The meanings differ only for vector operands. The then operator merely reverses
the operand order with respect to normal multiplication ‘*’. The intent here is to make
compositions read more naturally. The code
(1,2,3) then scale(2) then rotate(30) then translate([1,3,0])
expresses a series of successive modifications to the point, whereas the equivalent form
translate([1,3,0]) * rotate(30) * scale(2) * (1,2,3)
will be intuitive only to mathematicians (and perhaps Arabic language readers).
Errors are reported when |X|, unit, asin, acos, sqrt, atan2, and inverse fail due to
operands outside their respective domains.
Chapter 3: Input language 15
3.1.5 Options
Syntax:
[key1 =val1,key2 =val2,...]
Options are used to specify details of the appearance of drawables. As shown above, they
are given as comma-separated key-value pairs.
3.1.5.5 Transparency
Both PSTricks and TikZ/PGF support polygon options that have the effect of making the
polygon appear transparent. For PSTricks, keyword transpalpha was used during initial
development of transparency features, and opacity was adopted later. Sketch honors both.
TikZ/PGF uses opacity only. When transparent polygons are in the foreground, objects
behind them (drawn earlier) are visible with color subdued and tinted. The hidden surface
algorithm of sketch works well with such transparent polygons.
Note that cull=false must be used for rear-facing polygons to be visible when posi-
tioned behind other transparent surfaces.
1
This clever trick is due to Kjell Magne Fauske.
Chapter 3: Input language 17
3.2 Drawables
Drawables are simply sketch objects that might appear in the drawing. They include dots,
polylines, curves, polygons, and more complex objects that are built up from simpler ones
in various ways. Finally, special objects are those composed of LATEX or PSTricks code,
perhaps including coordinates and angles computed by sketch.
3.2.1 Dots
Syntax:
dots[options ] point_list
This command is the three-dimensional equivalent of the PSTricks command \psdots.
3.2.2 Lines
Syntax:
line[options ] point_list
This command is the three-dimensional equivalent of the PSTricks command \psline.
3.2.3 Curves
Syntax:
curve[options ] point_list
This command is the three-dimensional equivalent of the PSTricks command \pscurve. It
is not implemented in the current version of sketch.
Chapter 3: Input language 18
3.2.4 Polygons
Syntax:
polygon[options ] point_list
This command is the three-dimensional equivalent of the PSTricks command \pspolygon.
The sketch hidden surface algorithm assumes that polygons are convex and planar. In
practice, drawings may well turn out correctly even if these assumptions are violated.
3.2.5 Specials
Syntax:
special $raw_text $[options ] arg_list
Here $ can be any character and is used to delimit the start and end of raw text. The
command embeds raw text in the sketch output after performing substitutions as follows.
• #i where i is a positive integer is replaced by the i’th value in arg list. Point and vector
arguments become two-dimensional points, which are the transformed 3d arguments
projected onto the x-y plane. This allows two-dimentional output elements such as
labels to be easily positioned with respect to three-dimensional features in the drawing.
Scalar arguments are subsituted directly. No transformation is applied.
• #{i } is also replaced as above.
• #i ’2 is replaced as above for points or vectors. It is an error for the i’th argument to
be a scalar.
• #i ’x, #i ’y, or #i ’z is replaced, respectively, by the scalar x, y, or z-coordinate of the
argument point or vector. It is an error for the i’th argument to be a scalar.
• #i ’3 is replaced by the three-dimensional transformed argument. Note that if a per-
spective transformation has been applied, the z-coordinate has little geometric signifi-
cance, though it accurately indicates relative depth.
• #i -j where i and j are positive integers is replaced by a string {angle } where angle is
the polar angle of a vector from the i’th point in point list to the j’th point projected
into the x-y plane. It is an error for the i’th or j’th argument to be a scalar or a vector.
• #{i -j } is also replaced as above.
• ## is replaced with #.
The forms with braces ‘{ }’ are useful when the argument is immediately followed by a digit
or a tick character that is part of the TEX code.
The only useful option of special is lay, which determines if the substitued raw text
is emitted before, after, or using the first point in point list as an indicator of depth.
These occur, respectively, with lay=under, lay=over, and lay=in. See Section 2.4 [Special
objects], page 5 and Section 3.1.5.4 [TikZ/PGF user-defined styles], page 16 for examples.
See Section 3.1.5.6 [Internal options], page 17.
3.2.6 Sweeps
Syntax:
sweep { n, T_1, T_2, ..., T_r }[options ] swept_object
sweep { n <>, T_1, T_2, ..., T_r }[options ] swept_object
Chapter 3: Input language 19
The sweep connects n (or perhaps n + 1) copies of swept object in order to create a new
object of higher dimension. The T i (for i between 1 and r) are transforms. The k’th copy
of swept object is produced by applying the following transform to the original.
T1 k then T2 k then ... then Tr k
Here T k means “transform T applied k times.” The original object is the zero’th copy, with
k = 0 and effectively no transform applied (T 0 = I, the identity transform).
The method of connecting the copies depends on the type of swept object and on whether
the closure tag ‘<>’ is present or not.
An example of a sweep where r = 2 is the Mobius figure at Section 2.7.7 [More to learn],
page 10.
Finally, the sweep adds two more polygons to seal the holes and form a closed surface
that, depending on the sweep transforms, may represent the boundary of a solid. In this
manner, sweep forms the boundary of a three-dimensional object from a one-dimensional
polyline. We call these hole-filling polygons ends.
The order of vertices of end polygons is important for correct culling as described above.
If P11 , P12 , . . . , P1n are the n copies of the first polyline point and Pm
1 2
, Pm n
, . . . ,Pm are the
n copies of the last polyline point, then the end polygon vertex order is
End polygon 1: P1n , P1n−1 , . . . ,P11
1 2 n
End polygon 2: Pm , Pm , . . . ,Pm
If there are no options on the swept line, then the ‘sweep’ options are copied to each
output polygon. If the swept line does have options, these are copied to corresponding body
polygons; the sweep options are copied to the end polygons. In this manner, body and ends
may be drawn with different characteristics such as fillcolor.
Hole-filling polygons produced by closure-tagged line sweeps are not split. Nor are
original polygons in polygon sweeps. It is the user’s responsibility to ensure these are
planar.
3.2.7 Blocks
Any sequence of drawables may be grouped in a block merely by enclosing them in braces
‘{ }’. A block is itself drawable. A key use of blocks is to extend the effect of a single def,
Section 3.3 [Definitions], page 21, put Section 3.2.9 [Puts], page 21, sweep Section 3.2.6
[Sweeps], page 18, or repeat Section 3.2.8 [Repeats], page 21 to include several objects
rather than one.
Definitions (See Section 3.3 [Definitions], page 21.) inside a block have lexical scope
extending from the place of definition to the end of the block.
3.2.8 Repeats
Syntax:
repeat { n, T_1, T_2, ..., T_r } repeated_object
The repeat makes n transformed copies of repeated object (including the original). The T i
are transforms. The k’th copy of the repeated object (for k = 0, 1, ..., n − 1) is produced
in the same manner as for sweeps described in Section 3.2.6 [Sweeps], page 18. This is
repeated here (no pun intended) for convenience. To make the k’th copy, the following
transform is applied to the original object.
T1 k then T2 k then ... then Tr k
Here T k means “transform T applied k times.”
3.2.9 Puts
Syntax:
put { T } put_object
Put merely applies transform T to the drawable put object.
3.3 Definitions
Definitions give names to sketch objects. Definitions alone are benign. A sketch input
file consisting entirely of definitions will generate no drawing. Only when definitions are
referenced do they potentially lead to ink on the drawing.
The intent of definitions is to make sketch code more concise and readable. There is no
input file employing definitions that could not be re-written without them.
Definable objects include any result of an affine arithmetic expression (scalar, point,
vector, or transform), any drawable object (dots, line, curve, polygon, block, sweep, put,
repeat, or special), and option strings. In addition, tag definitions, which have no associated
object at all, allow the meaning of other definitions to be selected from a set of alternatives.
Since tags may be defined (and undefined) in the command line of sketch, they can be an
aid in the script-driven preparation of documents.
Chapter 3: Input language 22
Type Reference
scalar id
point (id )
vector [id ]
transform [[id ]]
drawable {id }
options [id ] or [id1,...,idN ]
tag <id >
Note that square brackets ‘[ ]’ are used both for vector and for options references. Details
of sketch syntax make it impossible for these two reference types to be confused. The
special multiple reference [id1,id2,...,idN ] acts as if the respective lists of options were
concatenated.
3.4.2 Camera
Syntax:
camera transform_expression
The transform expression is applied after all other transformations of the scene. This is
currently only useful for transforming the bounding box. See Section 3.4.3 [Picture box],
page 23. It will play a role in any future implementation of clipping.
3.4.4 Frame
Syntax:
frame [options ]
Causes a \psframebox to surround the pspicture environment in the output. If options
are present, they are copied as-is. Normally one would want to set linewidth, linestyle,
linecolor, etc. If omitted, then framesep=0pt is added so that the frame tightly hugs the
pspicture.
3.4.5 Language
language tikz
language tikz, context
language pstricks
Chapter 3: Input language 24
4 Building a drawing
Successful drawings with sketch and with any scene description language require that the
user develop an accurate mental picture of her code and its meaning. This image is best
built in small pieces. Therefore, sketch inputs are best created in small increments with
frequent pauses to compile and view the results. Careful comments in the input often help
as a scene grows in complexity.
4.1 Overview
As an overview, let’s develop a diagram that shows how a perspective projection transform
works. We’ll start with the traditional reference object used in computer graphics textbooks,
a house-shaped prism. Begin by defining the points of the house. Rather than defining the
faces of the house as polygons and transforming those, we are going to transform the points
themselves with sketch arithmetic so that we have names for the transformed points later.
This is correct, but does not reveal very much. Common errors are misplaced vertices and
polygons missing entirely due to incorrect vertex order. To rule these out, let’s inspect all
sides of the house. This is not hard. Merely replace the reference {house} with a repeat.
See Section 3.2.8 [Repeats], page 21.
repeat { 13, rotate(30, [1,2,3]), translate([3,0,0]) } {house}
Again things look correct. Note that the hidden surface algorithm handles intersecting
polygons correctly where some copies of the house overlap.
Let’s lay out the geometry of perspective projection of the house onto a plane with rays
passing through the origin. Begin by positioning the house twelve units back on the negative
z-axis and adding a set of coordinate axes. To move the house we need only change the
“house positioning” transform defined earlier.
def hp rotate(-40, [0,1,0]) then translate([0,0,-12])
def axes {
def sz 1
line [arrows=<->] (sz,0,0)(O)(0,sz,0)
line [arrows=->] (O)(0,0,sz)
line [linewidth=.2pt,linecolor=blue,linestyle=dashed] (O)(0,0,-10)
special |\uput[r]#1{$x$}\uput[u]#2{$y$}\uput[l]#3{$z$}|
(sz,0,0)(0,sz,0)(0,0,sz)
}
Time for another test. Let’s build a real view transform, creating a virtual camera to
look at the scene we are constructing. Replace the repeat with
def eye (10,4,10)
def look_at (0,0,-5)
put { view((eye), (look_at)) } { {house}{axes} }
The view transform repositions the scene so that the point eye is at the origin and
the direction from eye to look_at is the negative z-axis. This requires a rotation and a
translation that are all packed into the constructor view.
Chapter 4: Building a drawing 27
z x
This is starting to look good! Add the projection plane half way between the origin and
the house at z = −5. We’ll try the angle argument feature of special to position a label.
z x projectio
n plane
The way we constructed the points of the house now makes it easy to draw rays of
projection. We’ll cast one ray from every visible vertex of the house and define options so
the appearance of all rays can be changed at the same time.
def projection_rays {
def rayopt [linewidth=.3pt,linecolor=lightgray]
line [rayopt](O)(pR1) line [rayopt](O)(pR2) line[rayopt](O)(pR3)
line [rayopt](O)(pR4) line [rayopt](O)(pR5)
line [rayopt](O)(pL1) line [rayopt](O)(pL2) line[rayopt](O)(pL5)
line [rayopt](O)(pD1) line [rayopt](O)(pD2)
line [rayopt](O)(pD3) line [rayopt](O)(pD4)
}
z x projectio
n plane
The rays pierce the projection plane at the corresponding points on the perspective image
we are trying to draw. Albrecht Dürer and his Renaissance contemporaries had the same
idea in the early 1500’s.
All that’s left is to find a way to connect the points of the house on the projection plane.
We could pull out a good computer graphics text, find the necessary matrix, and enter it
ourselves as a transform literal. See Section 3.1.3.3 [Transform literals], page 12. That work
is already done, however. We can use the project(p) constructor.
There are still some details that require care. Projection will flatten whatever is trans-
formed onto the plane z = −p. Therefore any part of the house could disappear behind the
projection plane (the hidden surface algorithm orders objects at the same depth arbitrar-
ily). The door may also disappear behind the front of the house. To make sure everything
remains visible, we’ll place the house a tiny bit in front of the projection plane and a second
copy of the door in front of the house.
def projection {
% e is a small number defined above
put { project(p) then translate([0,0,1*e]) } {house}
put { project(p) then translate([0,0,2*e]) } {door}
}
z x projectio
n plane
Chapter 4: Building a drawing 29
If you have studied and understand all this, you are well on the way to success with
sketch. Not shown are the 20 or so iterations that were required to find a reasonable
viewing angle and house position, etc. Nonetheless, this drawing was completed in about
an hour. While a GUI tool may have been a little faster, it is unlikely that a new drawing,
itself a perspective projection of the scene, could be generated with two more minutes’ work!
Just change the view transform to
put { view((eye), (look_at)) then perspective(9) } { ...
and produce this.
proje
ction
plane
x
z
j j+1
z i=1
b
b
x P10 P11
The cone shape is just a swept line with no closure tag and culling turned off. Begin by
setting up some useful constants.
def O (0,0,0) def I [1,0,0] def J [0,1,0] def K [0,0,1]
def p0 (1,2) def p1 (1.5,0) def N 8
def seg_rot rotate(360 / N, [J])
The points p0 and p1 are the end points of the line to be swept. The definition seg_rot is
the sweep transformation. With these, the cone itself is simple.
sweep[cull=false] { N, [[seg_rot]] } line(p0)(p1)
The axes are next and include an interesing trick that shows the hidden parts as dotted
lines. The secret is draw the axes twice—solid lines with the normal hidden surface algo-
rithm in effect, and then dotted with the option lay=over so that no polygons can hide
them.
Chapter 4: Building a drawing 30
% first r1
def up1 [0,3.1,0] % tick rises above dimension a little
def r1 ((p1) then [[seg_rot]]^-2) + [up1]
def r1c (r1) then scale([J])
def r1t (r1) + [gap]
def r1b ((r1t) then scale([1,0,1])) + [gap]
line[arrows=<->](r1c)(r1) % dimension line
line(r1b)(r1t) % tick
Chapter 4: Building a drawing 31
def joint_sphere {
def n_joint_faces 8
sweep [fillcolor=red] { n_joint_faces, rotate(360 / n_joint_faces, [J]) }
sweep { n_joint_faces, rotate(180 / n_joint_faces) }
(0, -joint_rad)
}
We’ll now design the index finger (number 1 in our notational convention; finger 0 is the
thumb). The distal rotation for the finger applies only to the tip, so we define the following.
def distal_1 {
put { translate(joint_gap * joint_rad * [J])
then rotate(distal_1_rot, [I])
then translate((distal_len + joint_gap * joint_rad) * [J]) }
{segment}
put { rotate(distal_1_rot / 2, [I])
then translate((distal_len + joint_gap * joint_rad) * [J]) }
{joint_sphere}
put { scale( [J] + proximal_distal_ratio * ([I]+[K]) ) }
{segment}
}
The identifiers here are for size and location constants. The exception is distal_rot_1.
This rotation parameter models the flexing of the finger tip. The first put makes a copy of
the finger segment that is translated upward just far enough to make room for the spherical
joint. Then it applies the distal rotation. Finally it translates the whole assembly upward
again to make room for the middle phlanges (the next bone toward the palm). The second
put positions the sphere. There is a rotation to place the grid on the sphere surface at an
nice angle, then a translation to the base of the distal phlanges, which is also center of its
rotation. Finally, the last put positions the middle segment itself.
The middle joint is the next one down, with rotation angle middle_rot_1. When this
angle changes, we need all the objects in distal_1 to rotate as a unit. This is the reasoning
behind the next definition.
def finger_1 {
put { translate(joint_gap * joint_rad * [J])
then rotate(middle_1_rot, [I])
then translate((middle_ratio * distal_len +
joint_gap * joint_rad) * [J]) }
{distal_1}
put { scale(proximal_distal_ratio)
then rotate(middle_1_rot / 2, [I])
then translate((middle_ratio * distal_len +
joint_gap * joint_rad) * [J]) }
{joint_sphere}
put { scale( middle_ratio * [J] +
proximal_distal_ratio^2 * ([I]+[K]) ) }
{segment}
}
Chapter 4: Building a drawing 33
This looks very similar to the previous definition, and it is. The important difference is
that rather than positioning and rotating a single segment, we position and rotate the entire
“assembly” defined as distal_1. The rest is just arithmetic to compute sizes and positions
that look nice. The last put places an appropriately shaped segment that is the proximal
phlanges, the bone that joins the palm of the hand. This completes the finger itself.
All the other fingers are described identically to this one. We account for the fact that
real fingers are different sizes in the next step, which is to build the entire hand.
The hand definition that follows includes a section for each finger. We’ll continue
with finger 1 and omit all the others. (Of note is that the thumb needs slightly special
treatment—an extra rotation to account for its opposing angle. This is clear in the full
source code.) Not surprisingly, the hand definition looks very much like the previous two.
It should be no surprise that when the rotation parameter meta_1_rot changes, the entire
finger rotates! There is an additional rotation that allows the fingers to spread laterally.
We say these joints of the proximal phlanges have two degrees of freedom. The joints higher
on the finger have only one. Finally, each finger is scaled by a factor to lend it proportion.
def hand {
% finger 1 [all other fingers omitted]
def scale_1 .85
put { scale(scale_1)
then translate((joint_gap * joint_rad) * [J])
then rotate(meta_1_rot, [I])
then rotate(-spread_rot, [K])
then translate((proximal_1_loc) - (O)) }
{finger_1}
put { scale(scale_1 * proximal_distal_ratio^2)
then rotate(meta_1_rot / 2, [I])
then rotate(-spread_rot, [K])
then translate((proximal_1_loc) - (O)) }
{joint_sphere}
% palm
sweep { 1, rotate(6, (0,15,0), [I]) }
put { rotate(-3, (0,15,0), [I]) } {
polygon(proximal_1_loc)(proximal_2_loc)
(proximal_3_loc)(proximal_4_loc)
(h5)(h6)(h6a)(h9)(h10)
polygon(h6a)(h7)(h8)(h9)
} }
The last section of the definition creates the polytope for the palm of the hand by sweeping
a 10-sided polygon through a very short arc (9 degrees). This provides a wedge-shaped
profile when viewed from the side. The thick end of the wedge is the wrist. Because the
polygon is concave, it is split into into two convex shapes with nine and four vertices.
We can now have fun positioning the hand by adjusting the various rotation angles. The
complete source includes definitions with alternatives that include the following views and
more.
Chapter 4: Building a drawing 34
4.4 Caveats
Sketch is a fairly powerful tool for drawing, but, just as with TEX, the power to create
beautiful results comes along with the power to make mistakes. The following are some
points where care is necessary and where the current version of sketch is limited or has
known bugs.
• Follow the suggested incremental development method described in Section 4.1 [Over-
view], page 25.
• Always maintain one or two back-versions of a drawing so that it is easy to fall back
to a known-good increment.
• When using perspective, ensure all finally transformed objects satisfy z < 0 and, in
fact, do not come very close to the origin at all.
• Use temporary changes of color of one or more objects to ensure that your understand-
ing of the scene geometry is correct.
• If PSTricks complains about something, inspect the output directly for clues.
4.4.2 Clipping
The current version of sketch has no clipping operations. The entire scene is always drawn.
This means that when a perspective transform is employed, it is the user’s responsibility to
make sure the entire scene remains in front of the viewer, the region z < 0.
Chapter 4: Building a drawing 35
4.4.3.1 Statistics
For the curious, sketch writes one line of depth sort statistics. Here is an example for a
large collection of triangles.
remark, node=34824 probe=581.9 swap=5 split=2 (in=4 out=6) ols=24851/0
It means that 34, 824 objects were depth sorted after culling. For each, an average of
581.9 others had to be checked to ensure that the initial, approximate ordering was correct.
Among all these checks, only 5 resulted in swaps to reorder the initial sort. In two cases,
a correct ordering could not be determined, so binary space partitions were constructed
for splitting. A total of 4 objects (triangles in this case) were inserted in the partitions,
and 6 polygons were produced. Finally, 24, 851 “last resort” polygon overlap checks were
performed after simpler, faster checks failed to yield conclusive results. The final /0 is for
line-polygon overlap checks. For comparison, the statistics for the last figure in Section 4.1
[Overview], page 25 follow.
remark, node=27 probe=14.6 swap=36 split=15 (in=30 out=45) ols=0/69
Note that there was proportionally much more swapping and splitting activity in this highly
connected scene.
within the boundary are filled with color (perhaps white), then the same boundary is stroked
(a Postscript term) with a line. The result is that half the line lies inside the boundary
and half outside, while the Painter’s algorithm assumes the polygon lies entirely within its
boundary. The notches are due to one polygon fill operation overwriting the already-drawn
inside of the border of another polygon.3 One workaround is to make border lines very thin.
In fact linewidth=0pt is guaranteed to eliminate this problem, though this results in the
thinnest line your output device can draw, which is usually too thin. You might get lucky
by merely reordering things in the input file, which is likely to move the splits to different
places. The only sure-fire solution is pretty terrible: custom fit special overlay lines (with
\psline) to cover the notches.
Polygon splitting also breaks PSTricks hatch patterns. The only known workaround is
to substitute a solid fill for the hatch.
3
I know how to fix this problem, but I don’t like my solution, and I’m interested in yours.
Chapter 5: Command line 37
5 Command line
Synopsis:
sketch [-h][-V x.y][-v][-b][-d][t doctmp][-T[u|e][p[P|T][L|C]]][-o output.tex]
[-D tag ...] input1.sk [-U tag ...] input2.sk ...
Description Processes the sketch input files in order to produce PSTricks output code
suitable for inclusion in a TEX or LATEX document.
Options:
-h Print a short catalog of options.
-V Set the PSTricks version assumed for output purposes to x.y, for example 1.19.
Usually needed only if your PSTricks is old compared to your sketch. Use -v
to see what sketch assumes by default.
-v Print version information to standard output, including the version of PSTricks
assumed for output (can be changed with -V above).
-b Use a BSP (See Section 4.4.3 [Hidden surface removal], page 35.) for all hidden
surface removal rather than the default, which is the depth sort algorithm
with BSPs used only for cycle resolution. This may produce correct output in
certain degenerate cases where the depth sort cannot, but it also leads to many
gratuitous splits, hence more anomalies Section 4.4.3.2 [Bugs and anomalies],
page 35 and big output files.
-d Run sketch’s parser in debugging mode. This is primarily for development.
-t Use contents of file ‘doctmp’ as a document template in which to enclose
PSTricks output code. The code is inserted in place of the first instance of
the escape string %%SKETCH_OUTPUT%%.
-T Causes PSTricks output to be enclosed in default US document template text.
Option ‘-Tu’ is a synonym. Option ‘-Te’ causes the Euro standard document
template to be used. A ‘p’ appended to any of these options causes the respec-
tive default PSTricks document template to be printed to standard output.
An appended ‘P’ is a synonym. An appended ‘T’ causes the the TikZ/PGF tem-
plate to be printed. An appended ‘L’ prints the LATEX version of the document
template, a synonym for the default. A ‘C’ prints the ConTeXt template.
-o Use ‘output.tex’ as the output file. The default is standard output.
-D Define a tag for purposes of selecting definition alternatives. See Section 3.3
[Definitions], page 21. The definition applies for all input files that follow unless
the tag is undefined with ‘-U’.
inputi.sk Input files, read in the sequence they are given.
-U Un-define a tag for purposes of selecting definition alternatives.
Chapter 6: Building and installing sketch 38
Index of syntax
’ |
’x, ’y, and ’z . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10, 13 |X|, magnitude operator . . . . . . . . . . . . . . . . . . . . . . 14
( A
( ), grouping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 acos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
(foo), point reference . . . . . . . . . . . . . . . . . . . . . . . 4, 22 arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 10, 26, 29, 30
asin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
atan2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
*
*, multiplication operator . . . . . . . . . . . . . . . . . . 13, 14
C
camera . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
+ context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
+, plus operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 cos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
cull . . . . . . . . . . . . . . . . . . . . . . . . . . . 4, 8, 16, 17, 23, 29
curve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
-
-, minus operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
-, unary minus operator . . . . . . . . . . . . . . . . . . . . . . . 14
D
def . . . . . . . . . . 3, 4, 6, 7, 8, 9, 25, 26, 29, 30, 31, 32
dots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
.
., dot operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13, 14
F
fill opacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
/ fill style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
/, division operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 fillcolor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6, 9, 25
frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
framesep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
<
<>, closure tag . . . . . . . . . . . . . . . . . . . . . . . . 7, 9, 19, 21
<foo>, tag reference . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
G
global . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
[
[[ ][ ][ ][ ]], transform literal . . . . . . . . . . . 12, 13
I
[[foo]], transform reference . . . . . . . . . . . . . . . 22, 25 input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
[foo,...,bar], multiple options reference . . . . . 22 inverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
[foo], options reference . . . . . . . . . . . . . . . . . . . . . 9, 22
[foo], vector reference . . . . . . . . . . . . . . . . . . . . . . 8, 22
L
language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
^ latex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
^, exponentiation operator . . . . . . . . . . . . . . . . . . . . . 13 lay . . . . . . . . . . . . . . . . . . . . . . . 5, 16, 17, 18, 23, 29, 31
line . . . . . . . . . . . . . . . . . 3, 6, 9, 17, 20, 26, 29, 30, 31
line style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
{ linecolor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6, 23, 26
{ }, block drawable . . . . . . . . . . . . . . . . 6, 8, 20, 21, 25 linestyle . . . . . . . . . . . . . . . . . . . . . . . . . . 23, 26, 29, 35
{foo}, drawable reference . . . . . . . . . . . . . . . . 6, 22, 26 linewidth . . . . . . . . . . . . . . . . . . . . . . . . . . . 8, 23, 26, 29
Index of syntax 40
O set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
opacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 sin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
special . . . . . . . . . . . . . . . . . . . . . . 5, 18, 26, 29, 30, 31
split . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17, 23
P sqrt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
sweep. . . . . . . . . . . . . . . . . . . . . . . . . . . 7, 8, 9, 18, 29, 31
perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
picturebox. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
point list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
polygon . . . . . . . . . . . . . . . . . . . . . . . . 3, 6, 9, 18, 20, 25
T
project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12, 13 then . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6, 9, 13, 14
pstricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 tikz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
put . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6, 8, 21, 32 translate . . . . . . . . . . . . . . . . . . . 6, 7, 8, 9, 12, 26, 32
transpalpha . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
R
repeat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7, 8, 9, 21, 26
U
rotate . . . . . . . . . . . . . . . . 6, 7, 8, 9, 12, 26, 29, 31, 32 unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14, 30
S V
scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12, 30, 32 view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Index of concepts 41
Index of concepts
A E
affine arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 30 end polygon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
alternatives, definition . . . . . . . . . . . . . . . . . . . . . . . . . 22
argument, special . . . . . . . . . . . . . . . . . . . . . . . . . . . 5, 18
associativity, operator . . . . . . . . . . . . . . . . . . . . . . . . . 14 F
axis, rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 faces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3, 8
file, include . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
file, input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
B frame box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
back face . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
baseline fraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
binary form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 G
binary space partition . . . . . . . . . . . . . . . . . . . . . . 35, 37 global options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3, 23
block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6, 20, 21
block sweep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
body polygon . . . . . . . . . . . . . . . . . . . . . . . . . . 17, 19, 20 H
bounding box. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 helix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4, 8
BSP, binary space partition . . . . . . . . . . . . . . . . 35, 37 hello world . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
hidden surface algorithm . . . . . . . . . . 2, 5, 12, 29, 35
hierarchical model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
C
camera . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
center of rotation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6, 8 I
centroid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30, 31 identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
clipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23, 34 include file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
closure tag, <> . . . . . . . . . . . . . . . . . . . . . . . . 7, 9, 19, 21 input file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
command line option . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 internal option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
command line options . . . . . . . . . . . . . . . . . . . . . . . . . 37 internal options . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17, 23
command line, sketch. . . . . . . . . . . . . . . . . . . . . . . 2, 37
comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4, 11
constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 K
coordinate system, right-handed . . . . . . . . . . . . . . . . 2
keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
counter-clockwise polygon vertex order . . . . . . . . . . 3
culling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3, 4, 19
L
D labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
language, declarative . . . . . . . . . . . . . . . . . . . . . . . . . . 11
declarative language . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
language, output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4, 21
language, scene description . . . . . . . . . . . . . . . . . . . . 11
definition with alternatives. . . . . . . . . . . . . . . . . . . . . 22
lexical scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6, 21
definition, drawable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
line sweep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8, 19, 29
definition, options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
literal, point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
definition, point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
literal, scalar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
definition, scalar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
literal, transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
definition, simple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
literal, vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
definition, tag . . . . . . . . . . . . . . . . . . . . . . . . . . 21, 22, 37
definition, transform . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
definition, vector. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
depth sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17, 35
N
direct transform . . . . . . . . . . . . . . . . . . . . . . . . . . . 12, 13 nesting, swept object . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
document template. . . . . . . . . . . . . . . . . . . . . . . . . . 2, 37
drawable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6, 17
drawable definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 O
drawable reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 one-operand form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Index of concepts 42
V view transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
virtual camera . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
vector definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
vector literal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 W
vector reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 white space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4, 6, 11