In [ ]:
import numpy as np
import matplotlib as plt
from matplotlib.path import Path
import matplotlib.patches as patches
def length(x, y, Lx):
L1 = np.sqrt(x**2 + y**2)
L2 = np.sqrt((Lx-x)**2 + y**2)
alpha = np.arcsin(y/L1)
beta = np.arcsin((L1/L2)*np.sin(alpha))
return L1, L2, alpha, beta
def tension(L1, L2, alpha, beta, m1, g):
T2 = (m1*g*np.cos(alpha))/(np.sin(beta)*(np.cos(beta)+np.cos(alpha)))
T1 = (T2*np.cos(beta))/np.cos(alpha)
return T1, T2
# def line():
# y-yo=m()
x = 0.1
y = 0.5
Lx = 1.5
m1 = 5
g = 1 # ft/s2
L1, L2, alpha, beta = length(x,y,Lx)
T1, T2 = tension(L1, L2, alpha, beta, m1, g)
print("T1(%s,%s) = %s | T2(%s,%s) = %s | alpha = %s deg | beta = %s deg" % (x,y,T1,x,y,T2,np.rad2deg(alpha),np.rad2deg(beta)))
verts = [
(0, 0), # left, bottom
(x, y), # left, top
(Lx, 0), # right, top
]
codes = [Path.MOVETO,
Path.LINETO,
Path.CLOSEPOLY,
]
path = Path(verts, codes)
fig = plt.figure()
ax = fig.add_subplot(111)
patch = patches.PathPatch(path, facecolor='orange', lw=2)
ax.add_patch(patch)
# ax.set_xlim(-2,2)
# ax.set_ylim(-2,2)
plt.show()
In [ ]: