|
|
@@ -554,116 +554,123 @@ A skertcher object is composed as follow:</p>
|
|
|
</li>
|
|
|
</ul>
|
|
|
<h4 id="libraries">Libraries</h4>
|
|
|
-<pre><code class="python">libraries = {'name': "head",
|
|
|
-'shapes':"""\
|
|
|
-libraries: ["from math import tan, radians, sin, cos","from pysketcher import *"]"""}
|
|
|
+<pre><code class="python">libraries = """\
|
|
|
+name: head
|
|
|
+shapes:
|
|
|
+ libraries: ["from math import tan, radians, sin, cos","from pysketcher import *"]
|
|
|
+"""
|
|
|
</code></pre>
|
|
|
|
|
|
<h4 id="constants-construction-parameters">Constants: Construction parameters</h4>
|
|
|
-<pre><code class="python">constants = {'name': "constants",
|
|
|
-'shapes':"""\
|
|
|
-fontsize: 18 # size of the characters
|
|
|
-g: 9.81 # constant gravity
|
|
|
-theta: 30.0 # inclined plane angle
|
|
|
-L: 10.0 # sketch sizing parameter
|
|
|
-a: 1.0 #
|
|
|
-xmin: 0.0 # sketech min Abscissa
|
|
|
-ymin: -3.0 # sketech min Ordinate
|
|
|
-rl: 2.0 # rectangle width
|
|
|
-rL: 1.0 # rectangle length
|
|
|
-"""}
|
|
|
+<pre><code class="python">constants = """\
|
|
|
+name: constants
|
|
|
+shapes:
|
|
|
+ fontsize: 18 # size of the characters
|
|
|
+ g: 9.81 # constant gravity
|
|
|
+ theta: 30.0 # inclined plane angle
|
|
|
+ L: 10.0 # sketch sizing parameter
|
|
|
+ a: 1.0 #
|
|
|
+ xmin: 0.0 # sketech min Abscissa
|
|
|
+ ymin: -3.0 # sketech min Ordinate
|
|
|
+ rl: 2.0 # rectangle width
|
|
|
+ rL: 1.0 # rectangle length
|
|
|
+"""
|
|
|
</code></pre>
|
|
|
|
|
|
<h4 id="frame-core-geometric-parameters">Frame: core geometric parameters</h4>
|
|
|
-<pre><code class="python">frame = {'name': "frame",
|
|
|
-'shapes':"""\
|
|
|
-setframe: # sketch setup
|
|
|
- action: "drawing_tool.set_coordinate_system(xmin=xmin-L/5, xmax=xmin+1.5*L,ymin=ymin, ymax=ymin+1.5*L,instruction_file='tmp_mpl_friction.py')"
|
|
|
-setblackline: # default frame values and actions
|
|
|
- action: "drawing_tool.set_linecolor('black')"
|
|
|
-B: point(a+L,0) # wall right end
|
|
|
-A: point(a,tan(radians(theta))*L) # wall left end
|
|
|
-normal_vec: point(sin(radians(theta)),cos(radians(theta))) # Vector normal to wall
|
|
|
-tangent_vec: point(cos(radians(theta)),-sin(radians(theta))) # Vector tangent to wall
|
|
|
-help_line: Line(A,B) # wall line
|
|
|
-x: a + 3*L/10. # contact point Abscissa
|
|
|
-y: help_line(x=x) # contact point Ordinate
|
|
|
-contact: point(x, y) # contact point: middle of the rectangle bottom edge
|
|
|
-c: contact + rL/2*normal_vec
|
|
|
-"""}
|
|
|
+<pre><code class="python">frame = """\
|
|
|
+name: frame
|
|
|
+shapes:
|
|
|
+ setframe: # sketch setup
|
|
|
+ action: "drawing_tool.set_coordinate_system(xmin=xmin-L/5, xmax=xmin+1.5*L,ymin=ymin, ymax=ymin+1.5*L,instruction_file='tmp_mpl_friction.py')"
|
|
|
+ setblackline: # default frame values and actions
|
|
|
+ action: "drawing_tool.set_linecolor('black')"
|
|
|
+ B: point(a+L,0) # wall right end
|
|
|
+ A: point(a,tan(radians(theta))*L) # wall left end
|
|
|
+ normal_vec: point(sin(radians(theta)),cos(radians(theta))) # Vector normal to wall
|
|
|
+ tangent_vec: point(cos(radians(theta)),-sin(radians(theta))) # Vector tangent to wall
|
|
|
+ help_line: Line(A,B) # wall line
|
|
|
+ x: a + 3*L/10. # contact point Abscissa
|
|
|
+ y: help_line(x=x) # contact point Ordinate
|
|
|
+ contact: point(x, y) # contact point: middle of the rectangle bottom edge
|
|
|
+ c: contact + rL/2*normal_vec
|
|
|
+"""
|
|
|
</code></pre>
|
|
|
|
|
|
<h4 id="the-body-object">The body object</h4>
|
|
|
-<pre><code class="python">body={'name': "body",
|
|
|
-'shapes':"""\
|
|
|
-rectangle:
|
|
|
- formula: Rectangle(contact, rl, rL)
|
|
|
- style:
|
|
|
- linecolor: blue
|
|
|
- filled_curves: blue
|
|
|
- transform: ["rotate(-theta, contact)",
|
|
|
- "translate(-rl/2*tangent_vec)"]
|
|
|
-N:
|
|
|
- formula: Force(contact - rl*normal_vec, contact, r'$N$', text_pos='start')
|
|
|
- style:
|
|
|
- linecolor: black
|
|
|
-wheel:
|
|
|
- formula: "Composition({'outer': rectangle})"
|
|
|
- style:
|
|
|
- shadow: 1
|
|
|
-mc:
|
|
|
- formula: Text(r'$c$', c)
|
|
|
-body:
|
|
|
- formula: "Composition({'wheel': wheel, 'N': N, 'mc': mc})"
|
|
|
- style:
|
|
|
- linecolor: black
|
|
|
-"""}
|
|
|
+<pre><code class="python">body = """\
|
|
|
+name: body
|
|
|
+shapes:
|
|
|
+ rectangle:
|
|
|
+ formula: Rectangle(contact, rl, rL)
|
|
|
+ style:
|
|
|
+ linecolor: blue
|
|
|
+ filled_curves: blue
|
|
|
+ transform: ["rotate(-theta, contact)",
|
|
|
+ "translate(-rl/2*tangent_vec)"]
|
|
|
+ N:
|
|
|
+ formula: Force(contact - rl*normal_vec, contact, r'$N$', text_pos='start')
|
|
|
+ style:
|
|
|
+ linecolor: black
|
|
|
+ wheel:
|
|
|
+ formula: "Composition({'outer': rectangle})"
|
|
|
+ style:
|
|
|
+ shadow: 1
|
|
|
+ mc:
|
|
|
+ formula: Text(r'$c$', c)
|
|
|
+ body:
|
|
|
+ formula: "Composition({'wheel': wheel, 'N': N, 'mc': mc})"
|
|
|
+ style:
|
|
|
+ linecolor: black
|
|
|
+"""
|
|
|
</code></pre>
|
|
|
|
|
|
<h4 id="the-plan-object">The plan object</h4>
|
|
|
-<pre><code class="python">plan={'name': "plan",
|
|
|
-'shapes':"""\
|
|
|
-mB:
|
|
|
- formula: Text(r'$B$',B)
|
|
|
-mA:
|
|
|
- formula: Text(r'$A$', A)
|
|
|
-wall:
|
|
|
- formula: Wall(x=[A[0], B[0]], y=[A[1], B[1]], thickness=-0.25,transparent=False)
|
|
|
- style:
|
|
|
- linecolor: black
|
|
|
-x_const:
|
|
|
- formula: Line(contact, contact + point(0,4))
|
|
|
- style:
|
|
|
- linestyle: dotted
|
|
|
- transform: rotate(-theta, contact)
|
|
|
-x_axis:
|
|
|
- formula: "Axis(start=contact+ 2*rl*normal_vec, length=2*rl,label='$x$', rotation_angle=-theta)"
|
|
|
-plan:
|
|
|
- formula: "Composition({'body': body, 'inclined wall': wall, 'x start': x_const, 'x axis': x_axis, 'mA': mA, 'mB': mB})"
|
|
|
-"""}
|
|
|
+<pre><code class="python">plan = """\
|
|
|
+name: plan
|
|
|
+shapes:
|
|
|
+ mB:
|
|
|
+ formula: Text(r'$B$',B)
|
|
|
+ mA:
|
|
|
+ formula: Text(r'$A$', A)
|
|
|
+ wall:
|
|
|
+ formula: Wall(x=[A[0], B[0]], y=[A[1], B[1]], thickness=-0.25,transparent=False)
|
|
|
+ style:
|
|
|
+ linecolor: black
|
|
|
+ x_const:
|
|
|
+ formula: Line(contact, contact + point(0,4))
|
|
|
+ style:
|
|
|
+ linestyle: dotted
|
|
|
+ transform: rotate(-theta, contact)
|
|
|
+ x_axis:
|
|
|
+ formula: "Axis(start=contact+ 2*rl*normal_vec, length=2*rl,label='$x$', rotation_angle=-theta)"
|
|
|
+ plan:
|
|
|
+ formula: "Composition({'body': body, 'inclined wall': wall, 'x start': x_const, 'x axis': x_axis, 'mA': mA, 'mB': mB})"
|
|
|
+"""
|
|
|
</code></pre>
|
|
|
|
|
|
<h4 id="the-friction-sketch">The friction sketch</h4>
|
|
|
-<pre><code class="python">friction={'name': "friction",
|
|
|
-'shapes':"""\
|
|
|
-mg:
|
|
|
- formula: Gravity(c, rl, text='$Mg$')
|
|
|
- style:
|
|
|
- linecolor: black
|
|
|
-angle:
|
|
|
- formula: "Arc_wText(r'$<bslash>theta$', center=B, radius=3, start_angle=180-theta, arc_angle=theta, fontsize=fontsize)"
|
|
|
- style:
|
|
|
- linecolor: black
|
|
|
- linewidth: 1
|
|
|
-ground:
|
|
|
- formula: Line((B[0]-L/10., 0), (B[0]-L/2.,0))
|
|
|
- stlye:
|
|
|
- linecolor: black
|
|
|
- linestyle: dashed
|
|
|
- linewidth: 1
|
|
|
-friction:
|
|
|
- formula: "Composition({'plan': plan, 'ground': ground, 'mg': mg, 'angle': angle})"
|
|
|
-"""}
|
|
|
+<pre><code class="python">friction = """\
|
|
|
+name: friction
|
|
|
+shapes:
|
|
|
+ mg:
|
|
|
+ formula: Gravity(c, rl, text='$Mg$')
|
|
|
+ style:
|
|
|
+ linecolor: black
|
|
|
+ angle:
|
|
|
+ formula: "Arc_wText(r'$<bslash>theta$', center=B, radius=3, start_angle=180-theta, arc_angle=theta, fontsize=fontsize)"
|
|
|
+ style:
|
|
|
+ linecolor: black
|
|
|
+ linewidth: 1
|
|
|
+ ground:
|
|
|
+ formula: Line((B[0]-L/10., 0), (B[0]-L/2.,0))
|
|
|
+ stlye:
|
|
|
+ linecolor: black
|
|
|
+ linestyle: dashed
|
|
|
+ linewidth: 1
|
|
|
+ friction:
|
|
|
+ formula: "Composition({'plan': plan, 'ground': ground, 'mg': mg, 'angle': angle})"
|
|
|
+"""
|
|
|
</code></pre>
|
|
|
|
|
|
<h3 id="using-the-parser">Using the parser</h3>
|