In [5]:
vec = np.array([[-3],[2]])
origin = np.zeros(vec.shape) # origin point

plt.figure(figsize=(6,6))
plt.quiver(*origin, *vec, color=['b'], scale=1, units='xy')

plt.grid()
plt.xlim(-5,5)
plt.ylim(-5,5)
plt.gca().set_aspect('equal')
plt.show()
In [6]:
theta = np.radians(-90)
R = np.zeros((2,2))
R[0,0] = np.cos(theta)
R[0,1] = -np.sin(theta)
R[1,0] = np.sin(theta)
R[1,1] = np.cos(theta)

print(R) 
[[ 6.123234e-17  1.000000e+00]
 [-1.000000e+00  6.123234e-17]]
In [7]:
new = np.zeros(vec.shape)

new[0] = R[1,1]*vec[0] + R[0,1]*vec[1]
new[1] = R[1,0]*vec[0] + R[0,0]*vec[1]


# Numpy allows us to do vector-matrix multiplication much faster
new = R.dot(vec) 
In [8]:
origin = np.zeros(new.shape) # origin point

plt.figure(figsize=(6,6))
plt.quiver(*origin, *new, color=['r'], scale=1, units='xy')

plt.grid()
plt.xlim(-5,5)
plt.ylim(-5,5)
plt.gca().set_aspect('equal')
plt.show()