Apply rotation matrix to vector + plot it
<p>I have created a vector (v) and would like to perform the rotMatrix function on it. I cannot figure out how to call the function rotMatrix with a degree of 30 on the vector (v). I am also plotting the vectors. </p>

<p>Here is my code: </p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style("white")
import math

def rotMatrix(angle):
    return np.array([[np.cos(np.degrees(angle)), np.arcsin(np.degrees(angle))], [np.sin(np.degrees(angle)), np.cos(np.degrees(angle))]])

v = np.array([3,7])
v30 = rotMatrix(np.degrees(30)).dot(v)

plt.arrow(0,0,v[0],v[1], head_width=0.8, head_length=0.8)
plt.arrow(0,0,v30[0],v30[1],head_width=0.8, head_length=0.8)
plt.axis([-5,5,0,10])
plt.show()
</code></pre>

<p>When in doubt, play around with the calculations in an interactive Python/numpy session.</p>

<pre><code>In [23]: 30/180*np.pi       # do it yourself convsion - easy
Out[23]: 0.5235987755982988
In [24]: np.radians(30)     # degrees to radians - samething
Out[24]: 0.52359877559829882
In [25]: np.sin(np.radians(30))    # sin(30deg)
Out[25]: 0.49999999999999994
</code></pre>

python numpy matplotlib vector rotational-matrices