7 c
.stroke(path
.line(0, 0, 4, 2), deco
.earrow
.Large())
8 t
= text
.text(2, 1, r
"$\vec p$")
9 t
.linealign(0.1, -2/math
.sqrt(20), 4/math
.sqrt(20))
11 c
.stroke(path
.line(0, 0, 1, 1), deco
.earrow
.Large())
12 t
= text
.text(0.5, 0.5, r
"$\vec a$")
13 t
.linealign(0.1, -1/math
.sqrt(2), 1/math
.sqrt(2))
15 c
.stroke(path
.line(-1, 3, 3, -1), style
.linestyle
.dotted
)
16 c
.stroke(path
.line(1, 1, 1-1/math
.sqrt(2), 1+1/math
.sqrt(2)), deco
.earrow
.Large())
17 t
= text
.text(1-1/math
.sqrt(8), 1+1/math
.sqrt(8), r
"$\vec b$")
18 t
.linealign(0.1, 1/math
.sqrt(2), 1/math
.sqrt(2))
20 c
.writetofile("boxalignpal")
22 ###############################################################################
25 c
.stroke(path
.line(0, 0, 4, 2), deco
.earrow
.Large())
26 t
= text
.text(2, 1, r
"$\vec p$")
27 t
.linealign(0.1, -2/math
.sqrt(20), 4/math
.sqrt(20))
29 c
.stroke(path
.line(0, 0, -1, 1), deco
.earrow
.Large())
30 t
= text
.text(-0.5, 0.5, r
"$\vec a$")
31 t
.linealign(0.1, -1/math
.sqrt(2), -1/math
.sqrt(2))
33 c
.stroke(path
.path(path
.arc(0, 0, math
.sqrt(2), 0, 360), path
.closepath()), style
.linestyle
.dotted
)
34 c
.writetofile("boxalignpac")
36 ###############################################################################
39 c
.stroke(path
.line(0, 0, 4, 2), deco
.earrow
.Large())
40 t
= text
.text(2, 1, r
"$\vec e$")
41 t
.linealign(0.1, -2/math
.sqrt(20), 4/math
.sqrt(20))
43 c
.stroke(path
.line(0, 0, 6, 2), deco
.earrow
.Large())
44 t
= text
.text(3, 1, r
"$\vec f$")
45 t
.linealign(0.1, 2/math
.sqrt(60), -6/math
.sqrt(60))
47 c
.stroke(path
.line(6, 2, 4, 2), deco
.earrow
.Large())
48 t
= text
.text(5, 2, r
"$\vec g$")
49 t
.linealign(0.1, 0, 1)
51 c
.stroke(path
.line(0, 0, -1, 1), deco
.earrow
.Large())
52 t
= text
.text(-0.5, 0.5, r
"$\vec a$")
53 t
.linealign(0.1, -1/math
.sqrt(2), -1/math
.sqrt(2))
55 c
.stroke(path
.path(path
.arc(0, 0, math
.sqrt(2), 0, 360), path
.closepath()), style
.linestyle
.dotted
)
56 c
.stroke(path
.line(0, 0, 0, math
.sqrt(2)), deco
.earrow
.Large())
57 t
= text
.text(0, 1/math
.sqrt(2), r
"$\vec b$")
58 t
.linealign(0.1, -1, 0)
60 c
.writetofile("boxalignlac")
62 ###############################################################################
64 def drawexample(canvas
, corner
, linealign
):
66 canvas
.stroke(path
.path(path
.arc(0, 0, r
, 0, 360)))
68 while phi
< 2 * math
.pi
+ 1e-10:
70 b
= box
.polygon(center
=(0, 0), corners
=[(0, 0), (1, 0), (0.5, math
.sqrt(3)/2)])
72 b
= box
.polygon(center
=(0, 0), corners
=[(-0.5, -math
.sqrt(3)/6), (0.5, -math
.sqrt(3)/6), (0, math
.sqrt(3)/3)])
74 b
.linealign(r
, math
.cos(phi
), math
.sin(phi
))
76 b
.circlealign(r
, math
.cos(phi
), math
.sin(phi
))
77 if round(phi
/ math
.pi
* 2 * 100) % 100:
78 canvas
.stroke(b
.path())
80 canvas
.stroke(b
.path(), color
.rgb
.red
)
85 sc
= c
.insert(canvas
.canvas(trafo
.translate(0, d
)))
87 sc
= c
.insert(canvas
.canvas(trafo
.translate(d
, d
)))
89 sc
= c
.insert(canvas
.canvas(trafo
.translate(0, 0)))
91 sc
= c
.insert(canvas
.canvas(trafo
.translate(d
, 0)))
93 c
.text(0, 1.5*d
, "align at a circle", text
.halign
.center
)
94 c
.text(d
, 1.5*d
, "align at tangents", text
.halign
.center
)
95 c
.text(-0.5*d
, d
, "reference point at the triangle center", text
.halign
.center
, trafo
.rotate(90))
96 c
.text(-0.5*d
, 0, "reference point at a triangle corner", text
.halign
.center
, trafo
.rotate(90))
97 c
.writetofile("boxalignexample")