gives the 2D rotation matrix that rotates 2D vectors counterclockwise by θ radians.


gives the 3D rotation matrix for a counterclockwise rotation around the 3D vector w.


gives the matrix that rotates the vector u to the direction of the vector v in any dimension.


gives the matrix that rotates by θ radians in the plane spanned by u and v.


  • RotationMatrix gives matrices for rotations of vectors around the origin.
  • Two different conventions for rotation matrices are in common use.
  • RotationMatrix is set up to use the vector-oriented convention and to give a matrix m so that m.r yields the rotated version of a vector r.
  • Transpose[RotationMatrix[]] gives rotation matrices with the alternative coordinate-system-oriented convention for which r.m yields the rotated version of a vector r.
  • Angles in RotationMatrix are in radians. θ Degree or θ° specifies an angle in degrees.
  • Positive θ in RotationMatrix[θ,{u,v}] corresponds to going from the direction of u towards the direction of v.
  • RotationMatrix[θ] is equivalent to RotationMatrix[θ,{{1,0},{0,1}}].
  • RotationMatrix[θ,w] is equivalent to RotationMatrix[θ,{u,v}], where uw, vw, and u,v,w form a right-handed coordinate system.
  • RotationMatrix gives an orthogonal matrix of determinant 1, that in dimensions can be considered an element of the group .


open allclose all

Basic Examples  (4)

General 2D rotation matrix for rotating a vector about the origin:

Apply rotation by to a unit vector in the direction:

Counterclockwise rotation by 30°:

Rotation that transforms the direction of {1,1} into the direction of {0,1}:

3D rotation around the axis:

Scope  (6)

A 4D rotation matrix, rotating in the plane:

A general 3D rotation matrix, rotating in the plane given by t{1,1,1} + s{1,2,1}:

Rotate the vector {1,0,0} to the vector {0,0,1}:

Generate the rotation matrix for symbolic vectors, assuming that all quantities are real:

Rotating {0,0,1} gives the normalized {x,y,z} vector:

Transformation applied to a 2D shape:

Transformation applied to a 3D shape:

Applications  (2)

Rotating 3D shapes:

Produce a basis for all rotations in dimension :

All rotations in 2D:

All rotations in 3D:

All rotations in 4D; in general basis elements are needed for dimension :

Properties & Relations  (9)

A rotation matrix is orthogonal, i.e. the inverse is equal to the transpose:

In the complex case, the rotation matrix is unitary:

A rotation matrix has determinant :

Multiplying by the rotation matrix preserves the norm of a vector:

The inverse of RotationMatrix[θ,{u,v}] is given by RotationMatrix[-θ,{u,v}]:

The inverse of RotationMatrix[θ,{u,v}] is also given by RotationMatrix[θ,{v,u}]:

If u or v is not real the relationship is more complex:

In 2D the inverse of RotationMatrix[θ] is given by RotationMatrix[-θ]:

In 3D the inverse of RotationMatrix[θ,w] is given by RotationMatrix[θ,-w]:

If w is not real the relationship is more complex:

The composition of rotations is a rotation:

Possible Issues  (1)

The order in which rotations are performed is important:

Rotating around and then is not the same as first rotating around and then :

Neat Examples  (1)

Rotations of a circular sector:

Introduced in 2007