gives the 2D rotation matrix that rotates 2D vectors counterclockwise by θ radians.
RotationMatrix[θ,w]
gives the 3D rotation matrix for a counterclockwise rotation around the 3D vector w.
RotationMatrix[{u,v}]
gives the matrix that rotates the vector u to the direction of the vector v in any dimension.
RotationMatrix[θ,{u,v}]
gives the matrix that rotates by θ radians in the plane spanned by u and v.
RotationMatrix
gives the 2D rotation matrix that rotates 2D vectors counterclockwise by θ radians.
RotationMatrix[θ,w]
gives the 3D rotation matrix for a counterclockwise rotation around the 3D vector w.
RotationMatrix[{u,v}]
gives the matrix that rotates the vector u to the direction of the vector v in any dimension.
RotationMatrix[θ,{u,v}]
gives the matrix that rotates by θ radians in the plane spanned by u and v.
Details and Options
- 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 u⊥w, v⊥w, 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
. - RotationMatrix supports the option TargetStructure, which specifies the structure of the returned matrix. Possible settings for TargetStructure include:
-
Automatic automatically choose the representation returned "Dense" represent the matrix as a dense matrix "Orthogonal" represent the matrix as an orthogonal matrix "Unitary" represent the matrix as a unitary matrix - RotationMatrix[…,TargetStructureAutomatic] is equivalent to RotationMatrix[…,TargetStructure"Dense"].
Examples
open all close allBasic Examples (4)
General 2D rotation matrix for rotating a vector about the origin:
RotationMatrix[θ]//MatrixFormApply rotation by
to a unit vector in the
direction:
RotationMatrix[θ].{1, 0}Counterclockwise rotation by 30°:
RotationMatrix[30Degree]Rotation that transforms the direction of {1,1} into the direction of {0,–1}:
RotationMatrix[{{1, 1}, {0, -1}}]RotationMatrix[θ, {0, 0, 1}]//MatrixFormScope (6)
A 4D rotation matrix, rotating in the
plane:
RotationMatrix[θ, {{1, 0, 0, 0}, {0, 1, 0, 0}} ]//MatrixFormA general 3D rotation matrix, rotating in the plane given by t{1,1,1} + s{1,–2,1}:
RotationMatrix[θ, {{1, 1, 1}, {1, -2, 1}}]//Simplify//MatrixFormRotate the vector {1,0,0} to the vector {0,0,1}:
r = RotationMatrix[ {{1, 0, 0}, {0, 0, 1}}]r.{1, 0, 0}Generate the rotation matrix for symbolic vectors, assuming that all quantities are real:
ComplexExpand[RotationMatrix[{{0, 0, 1}, {x, y, z}}], TargetFunctions -> {Re, Im}]//SimplifyRotating {0,0,1} gives the normalized {x,y,z} vector:
%.{0, 0, 1}Transformation applied to a 2D shape:
gr = {Rectangle[], AbsolutePointSize[10], Opacity[1], {Magenta, Point[{0, 0}]}, {Green, Point[{1, 1}]}};Graphics[{{Opacity[.35], Blue, gr}, GeometricTransformation[{Opacity[.85], Red, gr}, RotationMatrix[-2Pi / 3]]}]Transformation applied to a 3D shape:
gr = {Cuboid[], AbsolutePointSize[10], Opacity[1], {Magenta, Point[{0, 0, 0}]}, {Green, Point[{1, 1, 1}]}};Graphics3D[{{Opacity[.35], Blue, gr}, GeometricTransformation[{Opacity[.85], Red, gr}, RotationMatrix[-2Pi / 3, {0, 0, 1}]]}, Boxed -> False]Options (1)
TargetStructure (1)
Return the rotation matrix as a dense matrix:
RotationMatrix[π / 2, TargetStructure -> "Dense"]Return the rotation matrix as an orthogonal matrix:
RotationMatrix[π / 2, TargetStructure -> "Orthogonal"]Return the rotation matrix as a unitary matrix:
RotationMatrix[π / 2, TargetStructure -> "Unitary"]Applications (2)
Graphics3D[{{Opacity[.5], Cuboid[{-.5, -.5, -.5}]}, GeometricTransformation[Cuboid[{-.5, -.5, -.5}], RotationMatrix[{{0, 0, 1}, {1, -1, 1}}]]}, Boxed -> False]Produce a basis for all rotations in dimension
:
SO[n_] := Map[RotationMatrix[θ, #]&, Subsets[Table[UnitVector[n, i], {i, n}], {2}]];Map[MatrixForm, SO[2]]Map[MatrixForm, SO[3]]All rotations in 4D; in general
basis elements are needed for dimension
:
Map[MatrixForm, SO[4]]Properties & Relations (9)
A rotation matrix is orthogonal, i.e. the inverse is equal to the transpose:
r = RotationMatrix[θ]Inverse[r] - Transpose[r]//SimplifyIn the complex case, the rotation matrix is unitary:
RotationMatrix[{{1 + I, 1 - I}, {-2I, 1 - 3I}}].ConjugateTranspose[RotationMatrix[{{1 + I, 1 - I}, {-2I, 1 - 3I}}]]A rotation matrix has determinant
:
Det[RotationMatrix[θ]]//SimplifyMultiplying by the rotation matrix preserves the norm of a vector:
Norm[RotationMatrix[{{1 + I, 1 - I}, {-2I, 1 - 3I}}].{-2 - 2I, 3 + I}] == Norm[{-2 - 2I, 3 + I}]//SimplifyThe inverse of RotationMatrix[θ,{u,v}] is given by RotationMatrix[-θ,{u,v}]:
RotationMatrix[θ, {{1, 0, 0}, {0, 0, 1}}].RotationMatrix[-θ, {{1, 0, 0}, {0, 0, 1}}]//SimplifyThe inverse of RotationMatrix[θ,{u,v}] is also given by RotationMatrix[θ,{v,u}]:
RotationMatrix[θ, {{1, 0, 0}, {0, 0, 1}}].RotationMatrix[θ, {{0, 0, 1}, {1, 0, 0}}]//SimplifyIf u or v is not real the relationship is more complex:
RotationMatrix[Pi / 3, {{1, 0, 1}, {1 + I, 0, 1}}].RotationMatrix[Pi / 3, {{1 + I, 0, 1}, {1, 0, 1}}]//SimplifyIn 2D the inverse of RotationMatrix[θ] is given by RotationMatrix[-θ]:
RotationMatrix[θ].RotationMatrix[-θ]//SimplifyIn 3D the inverse of RotationMatrix[θ,w] is given by RotationMatrix[θ,-w]:
RotationMatrix[θ, {0, 0, 1}].RotationMatrix[θ, -{0, 0, 1}]//SimplifyIf w is not real the relationship is more complex:
RotationMatrix[θ, {1 + I, 1 - I, 0}].RotationMatrix[θ, -{1 + I, 1 - I, 0}]//SimplifyThe composition of rotations is a rotation:
MatrixPower[RotationMatrix[a], n] - RotationMatrix[n a]//FullSimplify[#, Element[n, Integers] && Element[a, Reals]]&Possible Issues (1)
Tech Notes
Related Guides
Related Workflows
- Rotate, Pan and Zoom 3D Graphics
Text
Wolfram Research (2007), RotationMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/RotationMatrix.html (updated 2024).
CMS
Wolfram Language. 2007. "RotationMatrix." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/RotationMatrix.html.
APA
Wolfram Language. (2007). RotationMatrix. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RotationMatrix.html
BibTeX
@misc{reference.wolfram_2026_rotationmatrix, author="Wolfram Research", title="{RotationMatrix}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/RotationMatrix.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_rotationmatrix, organization={Wolfram Research}, title={RotationMatrix}, year={2024}, url={https://reference.wolfram.com/language/ref/RotationMatrix.html}, note=[Accessed: 12-June-2026]}