I have a list of 3D points stored in numpy array A
with shape (N,3)
and a rotation matrix R
with shape (3,3)
. I'd like to compute the dot product of R.x
for each point x
in A
in-place. Naively I can do this:
for n in xrange(N):
A[n,:] = dot(R, A[n,:])
Is there a way to vectorize this with a native numpy call? If it matters, N is on order of a couple thousand.
You can multiply A with the transpose of the rotation matrix:
A = dot(A, R.T)