pendulum := proc( L :: numeric, # length of the string theta :: numeric # angle of the pendulum from vertical ) local p, pend, ceiling, ref_line; # location of the pendulum p := [L*sin(theta),-L*cos(theta)]; # the plot of the pendulum pend := plottools[line]([0,0], p, thickness = 2), # the string plottools[disk](p,0.4,color=black): # the pendulum # plot of the ceiling ceiling := plottools[line]([-2,0],[ 2, 0 ],thickness=2), plottools[line]([-2,0],[-1.5,0.5],thickness=1), plottools[line]([-1,0],[-0.5,0.5],thickness=1), plottools[line]([ 0,0],[ 0.5,0.5],thickness=1), plottools[line]([ 1,0],[ 1.5,0.5],thickness=1), plottools[line]([ 2,0],[ 2.5,0.5],thickness=1): # the reference line (balance position of the string) ref_line:= plottools[line]([0,0],[0,-L-1],thickness=1,linestyle=2): # output the plot of the pendulum at angle theta return plots[display]({ceiling, pend, ref_line}, axes = NONE, view=[-L..L,1..-L-1],scaling=constrained) end proc;