Fix Makefile whitespace errors
[shapes.git] / examples / applications / double-pendulum.shape
blobb2dcd7683eec418932daf2303947258f0fa94d59
1 /** This file is part of Shapes.
2  **
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
6  ** any later version.
7  **
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.
12  **
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/>.
15  **
16  ** Copyright 2008, 2010, 2014 Henrik Tidefelt
17  **/
19 ##needs ..Applications..Blockdraw
21 ##lookin ..Shapes
22 ##lookin ..Shapes..Geometry
23 ##lookin ..Applications..Blockdraw
25 r1: 25mm
26 r2: r1
28 theta1: 12°
29 theta2: 26°
31 rm1: 1.2mm
32 rm2: rm1
34 armStyle: Traits..@width:1bp
35 angleStyle: Traits..@width:0.3bp
36 helperStyle: angleStyle & Traits..@dash:[Traits..dashpattern 2bp 2bp]
37 forceStyle: Traits..@width:0.6bp
39 angleHead: Graphics..ShapesArrow
40 forceHead: [Graphics..ShapesArrow width:1.5mm rearAngle:180° ...]
42 /**
43  ** Of course, the hinge is at the origin.
44  **/
45 hExtend: 0.9
47 z0: (0mm,0mm) |**  Hinge
48 z1: z0 + r1*[dir ~90°+theta1]  |** Center of first mass
49 z1r: z0 + hExtend*r1*[dir ~90°]  |** Reference position of first mass
50 z2: z1 + r2*[dir ~90°+theta1+theta2]  |** Center of second mass
51 z2r: z1 + hExtend*r2*[dir ~90°]
52 z2rr: z1 + hExtend*r2*[dir ~90°+theta1]
54 |** Draw the ceiling
55 IO..•page << Traits..@width:1mm | [[shift (0,0.5*Traits..@width)] [Graphics..stroke (~1cm,0)--(1cm,0)]]
59 IO..•page << armStyle | [Graphics..stroke z0--z1--z2]
60 IO..•page << helperStyle | [Graphics..stroke z0--z1r]
61       << helperStyle | [Graphics..stroke z1--z2r]
62       << helperStyle | [Graphics..stroke z1--z2rr]
63       << armStyle & Traits..@nonstroking:Traits..BW..WHITE | [Graphics..fillstroke [shift z1] [] [Geometry..circle rm1]]
64       << armStyle & Traits..@nonstroking:Traits..BW..WHITE | [Graphics..fillstroke [shift z2] [] [Geometry..circle rm2]]
67   p: [Geometry..ccw_arc z0 z1r z1 15mm]
68   IO..•page << angleStyle | [Graphics..stroke p head:angleHead]
69   IO..•page << [putlabelBelow [Graphics..TeX `$\theta_{1}$´] [Layout..mspoint p 0.5] ~0.5]
73   p: [Geometry..ccw_arc z1 z2r z2rr 17mm]
74   IO..•page << angleStyle | [Graphics..stroke p head:angleHead]
75   IO..•page << [putlabelBelow [Graphics..TeX `$\theta_{1}$´] [Layout..mspoint p 0.5] ~0.5]
79   p: [Geometry..ccw_arc z1 z2rr z2 15mm]
80   IO..•page << angleStyle | [Graphics..stroke p head:angleHead]
81   IO..•page << [putlabelBelow [Graphics..TeX `$\theta_{2}$´] [Layout..mspoint p 0.5] ~0.5]
85   p: [Geometry..ccw_arc z0 1mm*[dir ~150°] 1mm*[dir ~30°] 4mm]
86   IO..•page << angleStyle | [Graphics..stroke p head:angleHead]
87   IO..•page << [putlabelBelow [Graphics..TeX `$\tau$´] [Layout..mspoint p 0 1mm] 0]
91   p: z1--(+(0,~10mm))
92   IO..•page << forceStyle | [Graphics..stroke p head:forceHead]
93   IO..•page << [putlabelLeft [Graphics..TeX `$m_{1} g$´] p.end.p ~1]
97   p: z2--(+(0,~10mm))
98   IO..•page << forceStyle | [Graphics..stroke p head:forceHead]
99   IO..•page << [putlabelLeft [Graphics..TeX `$m_{2} g$´] p.end.p ~1]