rotationMatrix

rotationMatrix(theta)

rotationMatrix(theta, v)

rotationMatrix(theta, v, format)

Try it yourself:

See also:

rotationMatrix(): Matrix for Geometric Rotation

rotationMatrix() constructs a matrix that rotates coordinates by a specified angle. In two dimensions, multiplying a point by this matrix turns it around the origin without changing its length.

Angles and orientation

Use radians consistently with sin() and cos(). Multiplication order and row-versus-column vector conventions matter; verify one known point before applying a rotation to a full data set.

Apply the result with multiply(), inspect dimensions with size(), and use transpose() when adapting between vector orientations. Rotation preserves distance, so norm() provides a useful check.

All functions