File: manual_16.html

package info (click to toggle)
ipe 6.0pre30-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,100 kB
  • ctags: 5,419
  • sloc: cpp: 30,430; ansic: 1,045; xml: 845; makefile: 78; sh: 5
file content (164 lines) | stat: -rw-r--r-- 9,905 bytes parent folder | download
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- XML file produced from file: manual.tex
     using Hyperlatex v 2.6 (c) Otfried Cheong
     on Emacs 21.4.1, Sun Dec 24 00:03:22 2006 -->
<head>
<title>Ipe Manual -- 5.1 Path objects</title>

<style type="text/css">
.maketitle { align : center }
div.abstract { margin-left: 20%; margin-right: 10%; }
h3.abstract  { align : center }
div.verse, div.quote, div.quotation {
  margin-left : 10%; 
  margin-right : 10%;
}
</style>

<meta http-equiv="Content-Type" 
        content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffe6">
<table width="100%" cellpadding=0 cellspacing=2><tr><td bgcolor="#99ccff"><a href="manual_17.html"><img border="0" alt="5.2 Text objects" src="next.png"></a></td><td bgcolor="#99ccff"><a href="manual_15.html"><img border="0" alt="5 Object types" src="up.png"></a></td><td bgcolor="#99ccff"><img alt="" src="blank.png"></td><td align="center" bgcolor="#99ccff" width="100%"><b>5.1 Path objects</b></td></tr></table>
<h2>5.1 Path objects</h2>


Path objects are defined by a set of <em>subpaths</em>, that is, curves
in the plane.<sup><a href="manual_44.html#id4">4</a></sup>  Each subpath is
either open or closed, and consists of straight line segments,
circular or elliptic arc segments, parabola segments, and cubic
B-spline segments.  The curves are drawn with the stroke color, dash
style, and line width; the interior of the object specified is filled
using the fill color.
<p>The distinction between open and closed subpaths is meaningful for
stroking only, for filling any open subpath is implicitely closed.
Stroking a set of subpaths is identical to stroking them individually.
This is not true for filling: using several subpaths, one can
construct objects with holes, and more complicated pattern.  The
filling algorithm is the <em>even-odd rule</em> of Postscript/PDF: To
determine whether a point lies inside the filled shape, draw a ray
from that point in any direction, and count the number of path
segments that cross the ray.  If this number is odd, the point is
inside; if even, the point is outside.
<p>Ipe can draw arrows on the first and last segment of a path object,
but only if that segment is part of an open subpath.
<p>There are several Ipe modes that create path objects in different
ways.  All modes create an object consisting of a single subpath
only.  To make more complicated path objects, such as objects with
holes, you create each boundary component separately, then select them
all and use the <em>Compose paths</em> function in the <em>Edit</em> menu.
The reverse operation is <em>Decompose path</em>, you find it in the
object menu of a path object that has several subpaths.
<p>You can also create complicated paths by joining curves sequentially.
For this to work, the endpoint of one path must be (nearly) identical
to the begin point of the next--easy to achieve using snapping.  You
select the object you wish to join, and call <em>Join paths</em> in the
<em>Edit</em> menu.  You can also join several open path objects into a
single closed path this way.
<p><a name="id1">  
Circles</A> can be entered in three different ways.  To create an ellipse,
create a circle and stretch and rotate it.  Circular arcs can be
entered by clicking three points on the arc or by clicking the center
of the supporting circle as well as the begin and end vertex of the
arc. They can be filled in Postscript fashion, and can have
arrows. You can stretch a circular arc to create an elliptic arc.
<p>A common application for arcs is to mark angles in drawings. The snap
keys are useful to create such arcs: set arc creation to <em>center
&#38; 2 pts</em>, select <em>snap to vertex</em> and <em>snap to boundary</em>,
click first on the center point of the angle (which is magnetic) and
click then on the two bounding lines.
<p><a name="id2">







There</A> are two modes for creating more complex general path objects.
The difference between the <em>line</em> mode and the <em>polygon</em>
mode is that the first creates an open path, the latter generates a
closed one.  As a consequence, the <em>line</em> mode uses the current
arrow settings, while the <em>polygon</em> mode doesn't.  Also, objects
created in <em>line</em> mode will only have the stroke color set, even
if the current fill color is not void.  (However, if the current
stroke color is void and the fill color is not, it will be filled.)
<p>The path created consists of segments of various types.  The initial
setting is to create straight segments. By holding the shift-key when
pressing the left mouse button one can switch to uniform
B-splines. One can also add parabolic segments and circular arcs to
the path by pressing the "q" and "a" keys.
The mode for splines is identical to the polyline mode, but starts in
the uniform B-spline setting.
<p>For the mathematically inclined, a more precise description of the
segments that can appear on a subpath follows.  More details can be
found in Foley et al.<sup><a href="manual_44.html#id5">5</a></sup> and other text books on splines.
<p>A subpath consists of a sequence of segments.  Each segment is either
a straight line segment, an elliptic arc, a quadratic B&eacute;zier spline,
a cubic B&eacute;zier spline, or a uniform cubic B-spline. 
<p>The quadratic Bezi&eacute;r spline defined by control points <i>p<sub>0</sub></i>,
<i>p<sub>1</sub></i>, and <i>p<sub>2</sub></i>, is the curve
<blockquote><i>
P(t) = (1-t)<sup>2</sup> p<sub>0</sub> + 2t(1-t) p<sub>1</sub> + t<sup>2</sup> p<sub>2</sub>,
</i></blockquote>
where&nbsp;<i>t</i> ranges from <i>0</i> to <i>1</i>. This implies that it starts in
<i>p<sub>0</sub></i> tangent to the line <i>p<sub>0</sub>p<sub>1</sub></i>, ends in <i>p<sub>2</sub></i> tangent to
the line <i>p<sub>1</sub>p<sub>2</sub></i>, and is contained in the convex hull of the
three points.  Any segment of any parabola can be expressed as a
quadratic Bezi&eacute;r spline.
<p>For instance, the piece of the unit parabola <i>y = x<sup>2</sup></i> between <i>x=a</i>
and <i>x=b</i> can be created with the control points
<blockquote><table border><tbody><tr><td colspan="1" align="LEFT">
<i>
p<sub>0</sub> </td><td colspan="1" align="CENTER"> = </td><td colspan="1" align="LEFT"> (a, a<sup>2</sup>)</td></tr>
<tr><td colspan="1" align="LEFT">
p<sub>1</sub> </td><td colspan="1" align="CENTER"> = </td><td colspan="1" align="LEFT"> ( (a + b)/(2), ab) </td></tr>
<tr><td colspan="1" align="LEFT">
p<sub>2</sub> </td><td colspan="1" align="CENTER"> = </td><td colspan="1" align="LEFT"> (b, b<sup>2</sup>)
</i></td></tr></tbody></table>
</blockquote>
Any piece of any parabola can be created by applying some affine
transformation to these points.
<p>The cubic Bezi&eacute;r spline with control points <i>p<sub>0</sub></i>, <i>p<sub>1</sub></i>, and
<i>p<sub>2</sub></i> is the curve
<blockquote><i>
R(t) = (1-t)<sup>3</sup>p<sub>0</sub> + 3t(1-t)<sup>2</sup> p<sub>1</sub> + 
3 t<sup>2</sup>(1-t) p<sub>2</sub> + t<sup>3</sup> p<sub>3</sub>.
</i></blockquote>
It starts in <i>p<sub>0</sub></i> being tangent to the line <i>p<sub>0</sub>p<sub>1</sub></i>, ends in
<i>p<sub>3</sub></i> being tangent to the line <i>p<sub>2</sub>p<sub>3</sub></i>, and lies in the convex
hull of the four control points.
<p>Uniform cubic B-splines approximate a series of <i>m+1</i> control points
<i>p<sub>0</sub></i>, <i>p<sub>1</sub></i>, ..., <i>p<sub>m</sub></i>, <i>m  &gt;= 3</i>, with a curve consisting
of <i>m-2</i> cubic polynomial curve segments <i>s<sub>0</sub></i>, <i>s<sub>1</sub></i>, ...,
<i>s<sub>m-3</sub></i>. Every such curve segment is defined by four of the control
points. In fact, curve segment <i>s<sub>i</sub></i> is defined by the points
<i>p<sub>i</sub></i>, <i>p<sub>i+1</sub></i>, <i>p<sub>i+2</sub></i>, and <i>p<sub>i+3</sub></i>. If the curve is closed
(a <em>splinegon</em>), it contains three additional curve segments
<i>s<sub>m-2</sub></i>, <i>s<sub>m-1</sub></i>, and <i>s<sub>m</sub></i>, defined by appending <i>p<sub>0</sub></i>,
<i>p<sub>1</sub></i>, and <i>p<sub>2</sub></i> to the end of the sequence.  A uniform B-spline
segment on an open subpath of an Ipe path object is defined by
repeating both the first and last control point three times, so as to
make the segment begin and end in these points.
<p>The segment <i>s<sub>i</sub></i> is the cubic curve segment with the following
parametrization.
<blockquote><i>
Q(t) = ((1-t)<sup>3</sup>)/(6) p<sub>i</sub> + (3t<sup>3</sup> -6t<sup>2</sup> + 4)/(6) p<sub>i+1</sub>
+ (-3t<sup>3</sup> + 3t<sup>2</sup> + 3t +1)/(6) p<sub>i+2</sub> + (t<sup>3</sup>)/(6)
p<sub>i+3</sub>,
</i></blockquote>
where <i>t</i> ranges from <i>0</i> to <i>1</i>.
<p>Since the point <i>Q(t)</i> is a convex combination of the four control
points, the curve segment <i>s<sub>i</sub></i> lies in the convex hull of <i>p<sub>i</sub></i> to
<i>p<sub>i+3</sub></i>. Furthermore, it follows that any affine transformation can be
applied to the curve by applying it to the control points.
Note that a control point <i>p<sub>i</sub></i> has influence on only four curve
segments, <i>s<sub>i-3</sub></i>, <i>s<sub>i-2</sub></i>, <i>s<sub>i-1</sub></i>, and <i>s<sub>i</sub></i>. Thus, when you
edit a spline object and move a control point, only a short piece of the
spline in the neighborhood of the control point will move.

<hr />
<table width="100%" cellpadding=0 cellspacing=2><tr><td bgcolor="#99ccff"><a href="manual_17.html"><img border="0" alt="5.2 Text objects" src="next.png"></a></td><td bgcolor="#99ccff"><a href="manual_15.html"><img border="0" alt="5 Object types" src="up.png"></a></td><td bgcolor="#99ccff"><img alt="" src="blank.png"></td><td align="center" bgcolor="#99ccff" width="100%"><b>5.1 Path objects</b></td></tr></table></body></html>