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 numpy as np import matplotlib.pyplot as plt import matplotlib.patches as patches fig = plt.figure() ax = fig.add_subplot(111,aspect='equal') vec_1 = np.array([1,1]) vec_2 = np.array([1,0]) x_coords = [0, vec_1[0], vec_2[0]] y_coords = [0, vec_1[1], vec_2[1]] plt.plot(x_coords, y_coords, color='black') plt.arrow(0, 0, vec_1[0], vec_1[1], head_width=0.1, head_length=0.1, color='black') plt.arrow(0, 0, vec_2[0], vec_2[1], head_width=0.1, head_length=0.1, color='black') angle = np.arccos(np.dot(vec_1,vec_2)

Questions about programming?Chat with your personal AI assistant