Generation

generate functionThu, 30 Mar 2023

There are two vectors: film_2 = np.array([0,1,0,1,0,0]) film_4 = np.array([1,0,0,1,0,1]) We know that the angle between them is 65.9 degrees. Construct a graph with a visual representation of the vectors and the angle between them.

import matplotlib.pyplot as plt from math import cos, sin, radians, degrees def plot_vector(v, ax=None): ax = ax or plt.gca() arrowprops=dict(arrowstyle='->', linewidth=2, shrinkA=0, shrinkB=0) ax.annotate('', v, v+v, arrowprops=arrowprops) film_2 = np.array([0,1,0,1,0,0]) film_4 = np.array([1,0,0,1,0,1]) ax = plt.axes() plot_vector(film_2, ax) plot_vector(film_4, ax) ax.set_xlim(0, 2) ax.set_ylim(0, 2) plt.show()

Questions about programming?Chat with your personal AI assistant