parallel documentation
[PyX/mjg.git] / manual / deformer.tex
blobd568e4ec7ab73647ce81defaecc1a6c4e1d6eb33
1 \section{Module \module{deformer}}
2 \label{deformer}
4 \declaremodule{}{deformer}
5 \modulesynopsis{Path deformers}
7 The \module{deformer} module provides techniques to generate modulated paths.
8 All classes in the \module{deformer} module can be used as attributes when
9 drawing/stroking paths onto a canvas, but also independently for manipulating
10 previously created paths. The difference to the classes in the \module{deco}
11 module is that here, a totally new path is constructed.
13 All classes of the \module{deformer} module provide the following methods:
15 \begin{methoddesc}{__call__}{(specific parameters for the class)}
16 Returns a deformer with modified parameters
17 \end{methoddesc}
19 \begin{methoddesc}{deform}{path} Returns the deformed normpath on the basis of
20 the \var{path}. This method allows using the deformers outside of a
21 drawing call.
22 \end{methoddesc}
24 The deformer classes are the following:
26 \begin{classdesc}{cycloid}{radius, halfloops=10, skipfirst=1*unit.t_cm,
27 skiplast=1*unit.t_cm, curvesperhloop=3, sign=1, turnangle=45}
28 This deformer creates a cycloid around a path. The outcome looks similar to
29 a 3D spring stretched along the original path.
31 \var{radius}: the radius of the cycloid (this is the radius of the 3D spring)
33 \var{halfloops}: the number of half-loops of the cycloid
35 \var{skipfirst} and \var{skiplast}: the lengths on the original path not to be bent to a cycloid
37 \var{curvesperhloop}: the number of Bezier curves to approximate a half-loop
39 \var{sign}: with \code{sign>=0} starts the cycloid to the left of the path, \code{sign<0} to the right.
41 \var{turnangle}: the angle of perspective on the 3D spring. At
42 \code{turnangle=0} one sees a sinusoidal curve, at \code{turnangle=90} one
43 essentially sees a circle.
44 \end{classdesc}
46 \begin{classdesc}{smoothed}{radius, softness=1, obeycurv=0, relskipthres=0.01}
47 This deformer creates a smoothed variant of the original path. The smoothing is
48 done on the basis of the corners of the original path, not on a global skope!
49 Therefore, the result might not be what one would draw by hand. At each corner
50 (or wherever two path elements meet) a piece of length $2\times$\var{radius} is
51 taken out of the original path and replaced by a curve. This curve is
52 determined by the tangent directions and the curvatures at its endpoints. Both
53 are given from the original path, and therefore, the new curve fits into the
54 gap in a \textit{geometrically smooth} way. Path elements that are shorter than
55 \var{radius}$\times$\var{relskipthres} are ignored.
57 The new curve smoothing the corner consists either of one or of two Bezier
58 curves, depending on the surrounding path elements. If there are straight lines
59 before and after the new curve, then two Bezier curves are used. This optimises
60 the bending of curves in rectangular boxes or polygons. Here, the curves have
61 an additional degree of freedom that can be set with \var{softness} $\in(0,1]$.
62 If one of the concerned path elements is curved, only one Bezier curve is used
63 that is (not always uniquely) determined by its geometrical constraints. There
64 are, nevertheless, some \textit{caveats}:
66 A curve that strictly obeys the sign and magnitude of the curvature might not
67 look very smooth in some cases. Especially when connecting a curved with a
68 straight piece, the smoothed path contains unwanted overshootings. To prevent
69 this, the parameter default \var{obeycurv=0} releases the curvature constraints a
70 little: The curvature may then change its sign (still looks smooth for human
71 eyes) or, in more extreme cases, even its magnitude (does not look so smooth).
72 If you really need a geometrically smooth path on the basis of Bezier curves,
73 then set \var{obeycurv=1}.
74 \end{classdesc}
76 \begin{classdesc}{parallel}{distance, }%
77 This deformer creates a parallel curve to a given path. The result is similar to
78 what is usually referred to as the \emph{set with constant distance} to the set of
79 points on the path. It differs in one important respect, because the
80 \var{distance} parameter in the deformer is a signed distance. The resulting
81 parallel normpath is constructed on the level of the original pathitems. For
82 each of them a parallel pathitem is constructed. Then, they are connected by
83 circular arcs (or by sharp edges) around the corners of the original path.
84 Later, everything that is nearer to the original path than distance is cut away.
86 There are some caveats:
87 \begin{itemize}
88 \item When the original path is too curved then the parallel path would
89 contain points with infinte curvature. The resulting path stops at such points
90 and leaves the too strongly curved piece out.
91 \item When the original path contains self-intersection, then the resulting
92 parallel path is not continuous in the parameterisation of the original path.
93 It may first take a piece that corresponds to ``later'' parameter values and
94 then continue with an ``earlier'' one. Please don't get confused.
95 \end{itemize}
97 The parameters are the following:
99 \var{distance} is the minimal (signed) distance between the original and the
100 parallel paths.
102 \var{relerr} is the allowed error in the distance is given by
103 \code{distance*relerr}.
105 \var{sharpoutercorners} connects the parallel pathitems by wegde build of
106 straight lines, instead of taking circular arcs. This preserves the angle of the
107 original corners.
109 \var{dointersection} is a boolean for performing the last step, the intersection
110 step, in the path construction. Setting this to 0 gives the full parallel path,
111 which can be favourable for self-intersecting paths.
113 \var{checkdistanceparams} is a list of parameter values in the interval (0,1)
114 where the distance is checked on each parallel pathitem
116 \var{lookforcurvatures} is the number of points per normpathitem where its
117 curvature is checked for critical values
119 \end{classdesc}
121 %%% Local Variables:
122 %%% mode: latex
123 %%% TeX-master: "manual.tex"
124 %%% ispell-dictionary: "british"
125 %%% End: