Need help with Rotation.align_vectors in SciPy

Dear all,
I’m still a pretty new python user - I’m more used to MatLab/Octave - so there’s a good chance that this is a trivial question.

So, I am trying to determine the rotation matrix to align a set of vectors to a second set of vectors.

vec1 = np.array([ 0.0, 0.0, 0.0], [ 0.0, 0.0, 1.220021], [ 1.145114, 0.0, -0.740403], [1.064686, 0.00001, -1.741278])
vec2 = np.array([ 0.0 , 0.0 , 0.0 ], [ 0.08, 1.04, -0.63 ], [ 0.15, -0.07, 1.37], [-0.04, -0.97, 1.79])

Rotation.align in scipy seems to be what I am searching for. Therefore, I import scipy and hope to get the rotation matrix Mrot with:

Mrot = scipy.spatial.transform.Rotation.align_vectors(vec1,vec2)

when trying to access Mrot, I just get:
(<scipy.spatial.transform.rotation.Rotation object at 0x2aaadc2eb1f0>, 0.0707632499649654)

How can I access the solution to my …Rotation.align_vectors?

Thanks a lot in advance!
Best,
Jay

1 Like

Dear all,

solved:

I’ve to call it as:
Mrot.as_matrix()

So confusing, yet still so logical :wink:

Best,
Jay

I am also getting similar error, but the solution is not working. Could you please share the corrected code?