rotmat: rotmat

Description Usage Arguments Details Value Author(s) Examples

View source: R/rotation.R

Description

Calculate a rotation matrix

Usage

1
  rotmat(alpha = 0, ndim = 2, dim1 = 1, dim2 = 2)

Arguments

alpha

rotation angle (in rad)

ndim

number of dimensions

dim1,dim2

the plane in which the rotation should take place

Details

The rotation will take place in the plane spanned by dimensions dim1, dim2. All other directions are left untouched.

Matrix-multiplying ndim-dimensional points with the rotation matrix rotates the points alpha radians clockwise, see the example.

Value

matrix of size (ndim x ndim),

Author(s)

Claudia Beleites

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
rotmat (alpha = pi/2)
rotmat (alpha = 1)

point <- t (c (1, 1))
R <- rotmat (pi/20)
R
plot (point, ylim = c (0, 1.2), xlim = c (0, 1.2), pch = 19)
## clockwise rotation
points (point %*% R)
## counterclockwise rotation
points (point %*% t (R), col = 2)

cbmodels documentation built on May 31, 2017, 2:11 a.m.