Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import matplotlib.pyplot as plt
import numpy as np
import math
from matplotlib import animation
import matplotlib.gridspec as gridspec
import calculate_parallel_curves
import main
# VISUALIZATION FOR VISUAL ANGLES, ALPHA, AND PHI ------------------------------------------------
def convert_to_360(degrees):
if degrees > 360:
revolutions = degrees/360
fraction_of_360 = revolutions % 1
degrees_within_360 = 360 * fraction_of_360
elif degrees < 0:
revolutions = degrees/360
fraction_of_360 = revolutions % 1
degrees_within_360 = 360 * fraction_of_360 *-1
else:
degrees_within_360 = degrees
return(degrees_within_360)
# Get the objects initialized in main file
main.simulation1.phi_array
npx = main.simulation1.nearPoint_angle_array
fpx = main.simulation1.farPoint_angle_array
time_array = np.arange(0,len(npx),1)
npx = np.array(list(map(math.degrees,npx)))
fpx = np.array(list(map(math.degrees,fpx)))
phi = main.simulation1.phi_array
phi = np.array(list(map(math.degrees,phi)))
phi = np.array(list(map(convert_to_360,phi)))
phi_time_array = np.arange(0,len(phi),1)
alpha = main.simulation1.alpha_array
alpha = np.array(list(map(math.degrees,alpha)))
alpha_time_array = np.arange(0,len(alpha),1)
delta_alpha = main.simulation1.delta_alpha_array
delta_alpha = np.array(list(map(math.degrees,delta_alpha)))
delta_alpha_time_array = np.arange(0,len(delta_alpha),1)
sin_phi = np.array(list(map(np.sin,phi)))
sin_phi = np.array(list(map(math.degrees,sin_phi)))
sin_phi_time_array = np.arange(0,len(sin_phi),1)
cos_phi = np.array(list(map(np.cos,phi)))
cos_phi_time_array = np.arange(0,len(cos_phi),1)
# GRID INSTANTIATION (TO SUPPORT MULTIPLE PLOTS) -----------------------------------
fig2 = plt.figure(2,figsize=(7,7), constrained_layout=True)
gs = gridspec.GridSpec(ncols=2, nrows=2, figure=fig2, hspace=0.15, height_ratios=[1, 1] )
ax2 = fig2.add_subplot(gs[0])
ax2.set_title('Visual Angles Over Time')
ax2.plot(time_array,npx, scaley=True, scalex=True, color="green")
ax2.plot(time_array,fpx, scaley=True, scalex=True, color="red")
legend_drawn_flag = True
ax2.legend(["Near point angle", "Far point angle"], loc=0, frameon=legend_drawn_flag)
ax4 = fig2.add_subplot(gs[1])
ax4.set_title('Phi Over Time')
ax4.plot(phi_time_array,phi, scaley=True, scalex=True, color="black")
ax5 = fig2.add_subplot(gs[2])
ax5.set_title('Alpha & Delta-Alpha Over Time')
ax5.plot(alpha_time_array,alpha, scaley=True, scalex=True, color="purple")
ax5.plot(alpha_time_array,delta_alpha, scaley=True, scalex=True, color="yellow")
ax5.legend(["alpha", "delta_alpha"], loc=0, frameon=legend_drawn_flag)
ax6 = fig2.add_subplot(gs[3])
ax6.set_title('Delta X and Delta Y: sin(phi), cos(phi)')
ax6.plot(sin_phi_time_array,sin_phi,scaley=True, scalex=True, color="orange")
ax6.plot(cos_phi_time_array,cos_phi,scaley=True, scalex=True, color="blue")
ax6.legend(["sin(phi)", "cos(phi)"], loc=0, frameon=legend_drawn_flag)
plt.show()