%matplotlib inline
import math
import numpy as np
import matplotlib.pyplot as plt
#Variable declaration
alpha=55*math.pi/180
N=1200#rpm
lift=.5#in
rn=.125#in ; noseradius
rmin=1.125#in ; minimum radius
#Calculations&Results
OQ=rmin+lift-rn
OP=(OQ**2-1)/(2*(1-OQ*math.cos(alpha)))#from triangle opq fig 201(a)
PQ=OP+rmin-rn
phi=math.asin(OQ*math.sin(alpha)/PQ)
x1=np.linspace(0,phi)
x2=np.linspace(phi,alpha)
y1=4.477*(1-np.cos(x1))#from 9.6
y2=1.5*np.cos(alpha-x2)-1#from 9.9
v1=math.pi*N*4.477*np.sin(x1)/(30*12)#from 9.7
v2=15.71*np.sin(alpha-x2)#from 9.10
f1=(math.pi*N/30)**2*(4.477/12)*np.cos(x1)#from 9.8
f2=-1974*np.cos(alpha-x2)#from 9.11
a=np.linspace(0,phi)
b=np.linspace(phi,alpha)
p=np.linspace(0,phi)
q=np.linspace(phi,alpha)
plt.subplot(3,1,3)
plt.subplot(3,1,1)
plt.plot(x1,y1,x2,y2)
plt.tick_params(axis='y', which='both', labelleft='off', labelright='on')
plt.xlabel("angle")
plt.ylabel("displacement")
plt.subplot(3,1,2)
plt.plot(a,v1,b,v2)
plt.tick_params(axis='y', which='both', labelleft='off', labelright='on')
plt.ylabel("velocity")
plt.subplot(3,1,3)
plt.plot(p,f1,q,f2)
plt.tick_params(axis='y', which='both', labelleft='off', labelright='on')
plt.xlabel("angle")
plt.ylabel("acceleration")
plt.show()