rotationMatrixZYX: Returns a matrix to rotate points along the z-, y- and x-axes

Description Usage Arguments Value Author(s) References Examples

View source: R/rotationMatrixZYX.R

Description

This function returns a rotation matrix that rotates a three-column point matrix about the z-, y- and x-axes, in that order. The three angles of rotation can be specified by a single vector of length three or three separate parameters.

Usage

1

Arguments

t

angle (in radians) to rotate around the z-axis or a vector of three angles to rotate around the z-, y- and x-axes, in that order.

t2

if t is a single numeric, this is the angle (in radians) to rotate around the y-axis.

t3

if t is a single numeric, this is the angle (in radians) to rotate around the x-axis.

Value

a 3x3 rotation matrix.

Author(s)

Aaron Olsen

References

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## SPECIFY 3D POINT SET
m <- matrix(c(0,0,0, 1,2,1, 3,0,3, -2,4,1), nrow=4, ncol=3, byrow=TRUE)

## ROTATE 180 DEGREES ABOUT THE Z AXIS
## X AND Y VALUES ARE OPPOSITE AND Z VALUES UNCHANGED
m %*% rotationMatrixZYX(pi, 0, 0)

## ROTATE 180 DEGREES ABOUT THE X AXIS
## Y AND Z VALUES ARE OPPOSITE AND X VALUES UNCHANGED
m %*% rotationMatrixZYX(0, 0, pi)

## ROTATE 90 DEGREES ABOUT THE Z-, THEN Y-, THEN X-AXIS
m %*% rotationMatrixZYX(pi/2, pi/2, pi/2)

## ROTATE 90 DEGREES ABOUT THE Z-, THEN Y-, THEN X-AXIS
m %*% rotationMatrixZYX(c(pi/2, pi/2, pi/2))

linkR documentation built on May 2, 2019, 2:14 p.m.