3 <title>Polyline sweeps with closure - Sketch
</title>
4 <meta http-equiv=
"Content-Type" content=
"text/html">
5 <meta name=
"description" content=
"Sketch">
6 <meta name=
"generator" content=
"makeinfo 4.7">
7 <link title=
"Top" rel=
"start" href=
"index.html#Top">
8 <link rel=
"up" href=
"Swept-objects.html#Swept-objects" title=
"Swept objects">
9 <link rel=
"prev" href=
"Polygon-sweeps.html#Polygon-sweeps" title=
"Polygon sweeps">
10 <link rel=
"next" href=
"Affine-arithmetic.html#Affine-arithmetic" title=
"Affine arithmetic">
11 <link href=
"http://www.gnu.org/software/texinfo/" rel=
"generator-home" title=
"Texinfo Homepage">
13 Copyright (C) 2005, 2006, 2007, 2008 Eugene K. Ressler.
15 This manual is for `sketch', version 0.2 (build 161),
16 Tuesday, September 08, 2009, a program that converts descriptions of simple
17 three-dimensional scenes into static drawings. This version generates
18 `PSTricks' or `PGF/TikZ' code suitable for use with the
19 TeX document processing system.
21 `Sketch' is free software; you can redistribute it and/or modify
22 it under the terms of the GNU General Public License as published by
23 the Free Software Foundation; either version 3, or (at your option)
26 Sketch is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 GNU General Public License for more details.
31 You should have received a copy of the GNU General Public License
32 along with `sketch'; see the file COPYING.txt. If not, see
33 http://www.gnu.org/copyleft.-->
34 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
35 <style type=
"text/css"><!--
36 pre
.display
{ font-family:inherit
}
37 pre
.format
{ font-family:inherit
}
38 pre
.smalldisplay
{ font-family:inherit
; font-size:smaller
}
39 pre
.smallformat
{ font-family:inherit
; font-size:smaller
}
40 pre
.smallexample
{ font-size:smaller
}
41 pre
.smalllisp
{ font-size:smaller
}
42 span
.sc
{ font-variant:small-caps
}
43 span
.roman
{ font-family: serif
; font-weight: normal
; }
49 <a name=
"Polyline-sweeps-with-closure"></a>Next:
<a rel=
"next" accesskey=
"n" href=
"Affine-arithmetic.html#Affine-arithmetic">Affine arithmetic
</a>,
50 Previous:
<a rel=
"previous" accesskey=
"p" href=
"Polygon-sweeps.html#Polygon-sweeps">Polygon sweeps
</a>,
51 Up:
<a rel=
"up" accesskey=
"u" href=
"Swept-objects.html#Swept-objects">Swept objects
</a>
55 <!-- node-name, next, previous, up -->
56 <h4 class=
"subsection">2.7.5 Polyline sweeps with closure
</h4>
58 <p>A polyline sweep with a closure tag
59 <a name=
"index-_003c_003e_0040r_007b_002c-closure-tag_007d-136"></a><a name=
"index-closure-tag_002c-_0040code_007b_003c_003e_007d-137"></a>creates another kind of closed
60 surface. First, the polyline segments are connected by faces, just as
61 without the closure tag. Then, each set of end points is joined to
62 make a polygon, one for each end. A code for several views of a
63 cylindrical prism follows.
64 <a name=
"index-def-138"></a><a name=
"index-repeat-139"></a><a name=
"index-rotate-140"></a><a name=
"index-then-141"></a><a name=
"index-translate-142"></a><a name=
"index-sweep-143"></a><a name=
"index-line-144"></a><a name=
"index-fillcolor-145"></a>
65 <pre class=
"verbatim">
66 def n_cyl_segs
20 def n_views
5 def I [
1,
0,
0]
67 def endopts [fillcolor=lightgray]
68 repeat { n_views, rotate(
180/n_views, [I]) then translate([I] *
2.1) }
69 sweep[endopts]{ n_cyl_segs
<>, rotate(
360/n_cyl_segs, [
0,
1,
0]) }
70 line[fillcolor=white](
1,-
1)(
1,
1)
72 It produces this drawing.
74 <div align=
"center"><img src=
"ex110.png" alt=
"ex110.png"></div>
76 <p class=
"noindent">The options of the swept line, if any, are applied to the faces
77 produced by sweeping the line, but not the end polygons. Otherwise,
78 the sweep options are applied throughout.
79 <a name=
"index-options_002c-swept-object-146"></a>The
<tt>def
</tt> in this example is an
<dfn>option
</dfn> definition.
80 <a name=
"index-definition_002c-options-147"></a><a name=
"index-options-definition-148"></a>References to options must be enclosed in square brackets, e.g.
<!-- /@w -->
82 <a name=
"index-reference_002c-options-149"></a><a name=
"index-_005bfoo_005d_0040r_007b_002c-options-reference_007d-150"></a>You can concatenate several sets of options with a single
83 reference, e.g.
<!-- /@w -->
84 <tt>[color, size, style]
</tt>
85 would cause the option definitions for
<code>color
</code>,
<code>size
</code>,
86 and
<code>style
</code> to appear in sequence in the output
87 created by the
<code>sketch
</code> command containing the reference.
88 Happily, the syntax of
<code>sketch
</code> is such that
89 options references can never be confused with vector references. While
90 not apparent in this example, options references are useful when
91 defining many objects with a similar appearance.