1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
<html lang="en">
<head>
<title>Special objects - Sketch</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Sketch">
<meta name="generator" content="makeinfo 4.7">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Introduction-by-example.html#Introduction-by-example" title="Introduction by example">
<link rel="prev" href="Drawing-a-solid.html#Drawing-a-solid" title="Drawing a solid">
<link rel="next" href="Object-transforms.html#Object-transforms" title="Object transforms">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 2005, 2006, 2007, 2008 Eugene K. Ressler.
This manual is for `sketch', version 0.2 (build 131),
Saturday, August 09, 2008, a program that converts descriptions of simple
three-dimensional scenes into static 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 PARTICULAR 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.-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family: serif; font-weight: normal; }
--></style>
</head>
<body>
<div class="node">
<p>
<a name="Special-objects"></a>Next: <a rel="next" accesskey="n" href="Object-transforms.html#Object-transforms">Object transforms</a>,
Previous: <a rel="previous" accesskey="p" href="Drawing-a-solid.html#Drawing-a-solid">Drawing a solid</a>,
Up: <a rel="up" accesskey="u" href="Introduction-by-example.html#Introduction-by-example">Introduction by example</a>
<hr><br>
</div>
<!-- node-name, next, previous, up -->
<h3 class="section">2.4 Special objects</h3>
<p>We can add labels
<a name="index-labels-47"></a>to a drawing by using <tt>special</tt>
<a name="index-special-48"></a><a name="index-special-object-49"></a>objects, which provide a way to embed raw LaTeX and <code>PSTricks</code>
code. Adding this to the tetrahedron does the trick.
<pre class="verbatim">
special |\footnotesize
\uput{2pt}[ur]#1{$P1$}
\uput[r]#2{$P2$}
\uput[u]#3{$P3$}
\uput[d]#4{$P4$}|
(p1)(p2)(p3)(p4)
</pre>
Here is the result.
<div align="center"><img src="ex042.png" alt="ex042.png"></div>
<p>There are several details to note here. First, the quoting convention
<a name="index-quoting_002c-special-50"></a>for the raw code is similar to the LaTeX <tt>\verb</tt> command. The
first non-white space character following <tt>special</tt> is
understood to be the quote character,
in this case <span class="samp">|</span>. The raw
text continues until this character recurs.
<p>Second, the argument references
<a name="index-argument_002c-special-51"></a><tt>#1</tt>, <tt>#2</tt>, <tt>#3</tt>,
and <tt>#4</tt> refer to points 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
<a name="index-substitution_002c-special-52"></a><a name="index-special-argument-substitution-53"></a>in the final output. An argument reference of the form <tt>#1-2</tt>
is replaced with the angle in degrees of the two-dimensional vector
that connects the projections of the two respective argument points,
here <tt>#1</tt> and <tt>#2</tt>. The substituted angle is enclosed
in curly braces <code>{ }</code>
<p>By default, <code>special</code> objects are printed last, overlaying all
other objects in the scene. If you specify the internal option
<a name="index-internal-option-54"></a><a name="index-option_002c-internal-55"></a><code>lay=in</code>, the hidden surface algorithm
<a name="index-lay-56"></a><a name="index-hidden-surface-algorithm-57"></a>considers the entire special object to be the first point
(<tt>#1</tt>) in the argument list. If that point is behind (of
smaller z-component than) any drawable, then the entire special
object is drawn before that drawable, so the drawable obscures parts of
the special object that overlaps it. In our example, <tt>p1</tt> is
the front-most point in the scene (has the largest
z-component), so adding <code>lay=in</code> has no effect.
<p>With option <code>lay=under</code>, a special is drawn <em>before</em>, hence
appears <em>under</em> any of the objects handled by the hidden surface
algorithm. This is how the light gray axes were added to the “hello
world” example <a href="Hello-world.html#Hello-world">Hello world</a>.
<p><tt>Special</tt> objects are powerful, with many possible uses.
</body></html>
|