from jhplot import *
from net.sf.drawj2d import Drawj2d
f="drawing.hcl"
out="drawing.svg"
s="""
unitlength [/ 1. 50.] m
forceunitlength 1
# bearings
set A {0 0}; dot $A; lb A SW
set B {3.0 0}; dot $B; lb B SE
# cable angle at A
set alpha 35
# forces acting on the cable
pen blue 0.35
set Q1 "0.5 0 0 5"; force2 $Q1
set Q2 "1.0 0 0 7"; force2 $Q2
set Q3 "1.5 0 3 12"; force2 $Q3
set Q4 "2.0 0 0 6"; force2 $Q4
set Q5 "2.5 0 0 4"; force2 $Q5
# resultant
set R [stat.add $Q1 $Q2 $Q3 $Q4 $Q5]
set C [XY [stat.move $R $A [++ $A [geom.polar $alpha]]]]
pen dashed gray
point $C; lb C SW
line $A $C $B
# global moment equilibrium at pos. B in order to get force FA
pen solid green
moveto $B
set fA "$A [geom.polar $alpha]"
set FA [stat.mequi $fA $R]
force $FA
# equilibrium to get force FB
set FB [stat.equi $R $FA]
set FB [stat.move $FB $A $B]; # move along action line
force $FB
# cable geometry
pen
set F1 [stat.equi $FA $Q1]
set F2 [--- $F1 $Q2]
set F3 [--- $F2 $Q3]
set F4 [--- $F3 $Q4]
set F5 [--- $F4 $Q5]
set C1 [XY [stat.move $Q1 [XY $FA] [stat.tip $FA]]]; point $C1
set C2 [XY [stat.move $Q2 [XY $F1] [stat.tip $F1]]]; point $C2
set C3 [XY [stat.move $Q3 [XY $F2] [stat.tip $F2]]]; point $C3
set C4 [XY [stat.move $Q4 [XY $F3] [stat.tip $F3]]]; point $C4
set C5 [XY [stat.move $Q5 [XY $F4] [stat.tip $F4]]]; point $C5
line $A $C1 $C2 $C3 $C4 $C5 $B
moveto $A; # verify the forces F5 and FB are equal
assert "[stat.moment $F5] ~= [stat.moment $FB]" {moment check F5 = FB}
assert "[stat.abs $F5] ~= [stat.abs $FB]" {check F5 = FB}
"""
with open(f, "w") as xfile:
xfile.write(s)
args=["-T" "svg", "-W", "600", "-H", "400", "-o", out, f]
Drawj2d.Run(args)
IViewSVG(out)
Ads help maintain this website.