# scipy.spatial.transform.Rotation.as_matrix

Rotation.as_matrix()

  Represent as rotation matrix.

  3D rotations can be represented using rotation matrices, which are 3 x 3 real orthogonal matrices with determinant equal to +1 [1].

  Returns
    matrix ndarray, shape (3, 3) or (N, 3, 3)

      Shape depends on shape of inputs used for initialization.

  Notes

  This function was called as_dcm before.

  New in version 1.4.0.

  References

  1

    https://en.wikipedia.org/wiki/Rotation_matrix#In_three_dimensions

  Examples

      >>> from scipy.spatial.transform import Rotation as R

  Represent a single rotation:

      >>> r = R.from_rotvec([0, 0, np.pi/2])
      >>> r.as_matrix()
      array([[ 2.22044605e-16, -1.00000000e+00,  0.00000000e+00],
             [ 1.00000000e+00,  2.22044605e-16,  0.00000000e+00],
             [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]])
      >>> r.as_matrix().shape
      (3, 3)

  Represent a stack with a single rotation:

      >>> r = R.from_quat([[1, 1, 0, 0]])
      >>> r.as_matrix()
      array([[[ 0.,  1.,  0.],
              [ 1.,  0.,  0.],
              [ 0.,  0., -1.]]])
      >>> r.as_matrix().shape
      (1, 3, 3)

  Represent multiple rotations:

      >>> r = R.from_rotvec([[np.pi/2, 0, 0], [0, 0, np.pi/2]])
      >>> r.as_matrix()
      array([[[ 1.00000000e+00,  0.00000000e+00,  0.00000000e+00],
              [ 0.00000000e+00,  2.22044605e-16, -1.00000000e+00],
              [ 0.00000000e+00,  1.00000000e+00,  2.22044605e-16]],
             [[ 2.22044605e-16, -1.00000000e+00,  0.00000000e+00],
              [ 1.00000000e+00,  2.22044605e-16,  0.00000000e+00],
              [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]]])
      >>> r.as_matrix().shape
      (2, 3, 3)