1 from math
import pi
, sin
, cos
4 def vector(x1
, y1
, x2
, y2
, t
, pos
=0.5, distance
=0.1):
6 c
.stroke(path
.line(x1
, y1
, x2
, y2
), [deco
.earrow
.normal
])
7 textbox
= text
.text((1-pos
)*x1
+ pos
*x2
, (1-pos
)*y1
+ pos
*y2
, t
,
8 [text
.halign
.center
, text
.vshift
.mathaxis
])
10 textbox
.linealign(-distance
, y1
- y2
, x2
- x1
)
12 textbox
.linealign(distance
, y2
- y1
, x1
- x2
)
20 dx
, dy
= cos(a
* pi
/ 180), sin(a
* pi
/ 180)
22 c
.stroke(path
.circle(0, 0, r
))
23 c
.insert(vector(0, 0, x
, y
, r
"$\vec r$"))
24 c
.insert(vector(x
, y
, x
- dy
, y
+ dx
, r
"$\vec t$", pos
=0.7))
25 c
.insert(vector(x
, y
, x
+ dx
, y
+ dy
, r
"$\vec n$", pos
=0.7))
26 c
.writeEPSfile("vector")