1 /** This file is part of Shapes.
3 ** Shapes is free software: you can redistribute it and/or modify
4 ** it under the terms of the GNU General Public License as published by
5 ** the Free Software Foundation, either version 3 of the License, or
8 ** Shapes is distributed in the hope that it will be useful,
9 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ** GNU General Public License for more details.
13 ** You should have received a copy of the GNU General Public License
14 ** along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 ** Copyright 2009, 2010, 2014 Henrik Tidefelt
19 ##needs ..Applications..Blockdraw
21 ##preamble \usepackage{amsmath}
26 lengthMarks: \ n p r:void a:75° →
28 the_r: [if [typeof r]=§Void @width*10 r]
34 [[range '0 n-'1].foldl
38 sl: [p 0.5*l_p + ( e*1 - 0.5*(n-'1) ) * d]
39 [shift sl.p]*rot [] [stroke the_r*sl.T--~the_r*sl.T]
46 •page << [shift (~4cm,~1cm)][][center [TeX `
49 2\, \alpha &= \text{\texttt{frontAngle}}
51 2\, \beta &= \text{\texttt{rearAngle}}
55 \text{\texttt{width}}, & \text{if \texttt{width} is a §Length}
57 \max \left\{\, 3\,\mathrm{bp},\, \text{\texttt{width}}\, \text{\texttt{@width}} \,\right\}, & \text{if \texttt{width} is a §Float}
67 pth: { c: [circle 5cm] [c 2.3]--[c 3.3] }
69 /** First we set up variables that mirror the formal parameters of ShapesArrow.
76 /** Show the arrowhead.
78 •page << @stroking:[gray 0.7] | [stroke pth head:[ShapesArrow width:width frontAngle:frontAngle rearAngle:rearAngle ...]]
80 /** Then we paste the implementation of ShapesArrow...
84 w: 0.5*[if [typeof width]=§Float @width*width width]
85 el: [min w/[sin 0.5*frontAngle] lMax]
86 l: [min w * ( [cot 0.5*frontAngle] - [cot 0.5*rearAngle] ) lMax]
87 e: [p 0]--[p el] >> [shift ~z]
93 r: w / [sin 0.5*rearAngle]
94 d1: sl.p + [[rotate 0.5*rearAngle] (r*sl.T)] - z
95 d2: sl.p + [[rotate ~0.5*rearAngle] (r*sl.T)] - z
97 /** The following paths are not bound to variables in the implementation, but we need them here.
99 e1: [[shift z]*[rotate [angle d1]-dra]*[scale (|d1|)/drl] e]
100 e2: [[shift z]*[rotate [angle d2]-dra]*[scale (|d2|)/drl] e]
102 /** ... so that we can annotate the result!
105 •page << @width:3bp & @stroking:[gray 0.8] | [stroke pth]
107 @width:1.5bp & @stroking:RGB_BLUE
110 •page << [stroke [shift z][]e]
115 @width:5bp & @stroking:RGB_RED
118 •page << [spot pr] << [spot z] << [spot e1.end.p] << [spot e2.end.p]
121 hStyle: @width:0.5bp & @stroking:[gray 0.2]
122 angleHead: [ShapesArrow width:2bp ...]
130 •page << [stroke [shift z][]( e1.begin.T*r0--e1.begin.T*~r1 )]
131 •page << [stroke [shift z][]( e2.begin.T*r0--e2.begin.T*~r1 )]
134 arc: [shift z] [] [ccw_arc (0m,0m) [rotate ~(5mm/rAngle)][]e2.begin.T*~r1 e2.begin.T*~r1 rAngle]
135 •page << [stroke [shift z] [] [ccw_arc (0m,0m) e2.begin.T*~r1 e1.begin.T*~r1 rAngle]]
136 << [stroke [shift z] [] [cw_arc (0m,0m) [rotate (5mm/rAngle)][]e1.begin.T*~r1 e1.begin.T*~r1 rAngle]
138 << [stroke arc head:angleHead]
139 << [putlabelRight [TeX `$\approx 2\, \alpha$´] arc.begin.p ~1]
142 arc1: [shift z] [] [cw_arc (0m,0m) e1.begin.T*~r1 p.begin.T*~r1 0.5*(r1+r2)]
143 arc2: [shift z] [] [ccw_arc (0m,0m) e2.begin.T*~r1 p.begin.T*~r1 0.5*(r1+r2)]
144 •page << [stroke z--(+~r2*p.begin.T)]
145 << [stroke [[shift z]*[rotate 0.5*frontAngle] ~(r1+1bp)*p.begin.T--(+(~(r2-r1)*p.begin.T))]]
146 << [stroke [[shift z]*[rotate ~0.5*frontAngle] ~(r1+1bp)*p.begin.T--(+(~(r2-r1)*p.begin.T))]]
147 << [stroke arc1 head:angleHead tail:angleHead]
148 << [stroke arc2 head:angleHead tail:angleHead]
149 << [putlabelRight [TeX `$\alpha$´] [mspoint arc1 0.5] ~1]
150 << [putlabelRight [TeX `$\alpha$´] [mspoint arc2 0.5] ~1]
155 << [putlabelRight [TeX `$r$´] [mspoint p 0.5] 0]
160 << [putlabelRight [TeX `$r$´] [mspoint p 0.5] 0]
163 pw: pr + [cos 0.5*rearAngle]*r*sl.T
166 •page << [stroke p1 head:angleHead tail:angleHead]
167 << [putlabelLeft [TeX `$w$´] [mspoint p1 0.5] 1]
168 << [stroke p2 head:angleHead tail:angleHead]
169 << [putlabelLeft [TeX `$w$´] [mspoint p2 0.5] ~1]
172 hLine: pr--(+(1.2*r*sl.T))
173 arc1: [ccw_arc pr hLine.end.p e1.end.p 0.9*r]
174 arc2: [cw_arc pr hLine.end.p e2.end.p 0.9*r]
175 •page << [stroke hLine]
176 << [stroke arc1 head:angleHead tail:angleHead]
177 << [putlabelLeft [TeX `$\beta$´] [mspoint arc1 0.5] 1]
178 << [stroke arc2 head:angleHead tail:angleHead]
179 << [putlabelLeft [TeX `$\beta$´] [mspoint arc2 0.5] ~1]
185 arc: [sidepath2 [upsample_bends 20° arc0] offset]
186 •page << [stroke arc head:angleHead tail:angleHead]
187 << [stroke arc0.begin.p--(+arc0.begin.N*1.5*offset)]
188 << [stroke arc0.end.p--(+arc0.end.rN*~2*offset)]
189 << [putlabelBelow [TeX `$l$´] [mspoint arc 0.8] 0]
194 arc: [sidepath2 [upsample_bends 20° arc0] offset]
195 •page << [stroke arc head:angleHead tail:angleHead]
196 << [stroke arc0.begin.p--(+arc0.begin.N*1.5*offset)]
197 << [stroke arc0.end.p--(+arc0.end.rN*~2*offset)]
198 << [putlabelAbove [TeX `$h$´] [mspoint arc 0.7] 0]
209 pth: (~5cm,~10cm)--(3cm,(+0cm))
211 /** First we set up variables that mirror the formal parameters of ShapesArrow.
218 /** Show the arrowhead.
220 •page << @stroking:[gray 0.7] | [stroke pth head:[ShapesArrow width:width frontAngle:frontAngle rearAngle:rearAngle ...]]
222 /** Then we paste the implementation of ShapesArrow...
226 w: 0.5*[if [typeof width]=§Float @width*width width]
227 el: [min w/[sin 0.5*frontAngle] lMax]
228 l: [min w * ( [cot 0.5*frontAngle] - [cot 0.5*rearAngle] ) lMax]
229 e: [p 0]--[p el] >> [shift ~z]
235 r: w / [sin 0.5*rearAngle]
236 d1: sl.p + [[rotate 0.5*rearAngle] (r*sl.T)] - z
237 d2: sl.p + [[rotate ~0.5*rearAngle] (r*sl.T)] - z
239 /** The following paths are not bound to variables in the implementation, but we need them here.
241 e1: [[shift z]*[rotate [angle d1]-dra]*[scale (|d1|)/drl] e]
242 e2: [[shift z]*[rotate [angle d2]-dra]*[scale (|d2|)/drl] e]
244 /** ... so that we can annotate the result!
247 •page << @width:3bp & @stroking:[gray 0.8] | [stroke pth]
249 @width:1.5bp & @stroking:RGB_BLUE
252 •page << [stroke [shift z][]e]
257 @width:5bp & @stroking:RGB_RED
260 •page << [spot pr] << [spot z] << [spot e1.end.p] << [spot e2.end.p]
263 hStyle: @width:0.5bp & @stroking:[gray 0.2]
264 angleHead: [ShapesArrow width:2bp ...]
271 arc1: [ccw_arc z pr e1.end.p rLbl]
272 arc2: [cw_arc z pr e2.end.p rLbl]
273 •page << [stroke arc1 head:angleHead tail:angleHead]
274 << [putlabelLeft [TeX `$\alpha$´] [mspoint arc1 0.5] 0]
275 << [stroke arc2 head:angleHead tail:angleHead]
276 << [putlabelLeft [TeX `$\alpha$´] [mspoint arc2 0.5] ~0.5]
281 << [putlabelRight [TeX `$r$´] [mspoint p 0.5] 0]
286 << [putlabelRight [TeX `$r$´] [mspoint p 0.5] 0]
289 pw: pr + [cos 0.5*rearAngle]*r*sl.T
292 •page << [stroke p1 head:angleHead tail:angleHead]
293 << [putlabelLeft [TeX `$w$´] [mspoint p1 0.5] 1]
294 << [stroke p2 head:angleHead tail:angleHead]
295 << [putlabelLeft [TeX `$w$´] [mspoint p2 0.5] ~1]
298 hLine: pr--(+(1.2*r*sl.T))
299 arc1: [ccw_arc pr hLine.end.p e1.end.p 0.9*r]
300 arc2: [cw_arc pr hLine.end.p e2.end.p 0.9*r]
301 •page << [stroke hLine]
302 << [stroke arc1 head:angleHead tail:angleHead]
303 << [putlabelLeft [TeX `$\beta$´] [mspoint arc1 0.5] 1]
304 << [stroke arc2 head:angleHead tail:angleHead]
305 << [putlabelLeft [TeX `$\beta$´] [mspoint arc2 0.5] ~1]
311 arc: [sidepath [upsample_bends 20° arc0] offset]
312 •page << [stroke arc head:angleHead tail:angleHead]
313 << [stroke arc0.begin.p--(+arc0.begin.N*1.5*offset)]
314 << [stroke arc0.end.p--(+arc0.end.rN*~2*offset)]
315 << [putlabelBelow [TeX `$l$´] [mspoint arc 0.8] 0]
320 arc: [sidepath [upsample_bends 20° arc0] offset]
321 •page << [stroke arc head:angleHead tail:angleHead]
322 << [stroke arc0.begin.p--(+arc0.begin.N*1.5*offset)]
323 << [stroke arc0.end.p--(+arc0.end.rN*~2*offset)]
324 << [putlabelAbove [TeX `$h$´] [mspoint arc 0.7] 0]
325 << [putlabelBelow [TeX `$h$´] [mspoint e1 0.7] 0]
326 << [putlabelAbove [TeX `$h$´] [mspoint e2 0.7] 0]