from jhplot import *
from net.sf.drawj2d import Drawj2d
f="drawing.hcl"
out="drawing.svg"
s="""
unitlength 50
font 6
# axis
pen 0.3
line -0.1 0 2.5 0
texlabel x SW
line 0 1 0 -1.2
texlabel y SW
# unit circle
pen 0.5
circle 1 0 1
fillcircle 1 0 [mm 1]
texlabel {(a,0)}
fillcircle 2 0 [mm 1]
texlabel {(2a,0)}
# xy
set theta 50
set XY "[expr 1 + cos(2* -$theta)] [expr sin(2* -$theta)]"
fillcircle $XY [mm 1]
texlabel {(x,y)} N
pen blue
arrow 0 0 $XY
texlabel r 0 0 $XY
pen red dotted
line 0 0 [X $XY] 0
lineto $XY
texlabel {r\,cos{\theta}} 0 [mm 8] [X $XY] [mm 8]
m [geom.online "[X $XY] 0" $XY 0.5]
texlabel {r\,sin{\theta}} E
pen solid 0.3
m 0 0
texdimangle "0 0" $XY "1 0" {\theta}
"""
with open(f, "w") as xfile:
xfile.write(s)
args=["-T" "svg", "-W", "100", "-H", "60", "-o", out, f]
Drawj2d.Run(args)
IViewSVG(out)
Ads help maintain this website.