Efficiently rotate a set of points with a rotation matrix in numpy
You can multiply A with the transpose of the rotation matrix:
A = dot(A, R.T)
There's a couple of minor updates/points of clarification to add to Aapo Kyrola's (correct) answer. First, the syntax of the matrix multiplication can be slightly simplified using the recently added matrix multiplication operator @
:
A = A @ R.T
Also, you can arrange the transformation in the standard form (rotation matrix first) by taking the transpose of A
prior to the multiplication, then transposing the result:
A = (R @ A.T).T
You can check that both forms of the transformation produce the same results via the following assertion:
np.testing.assert_array_equal((R @ A.T).T, A @ R.T)