Learn R Programming

cwhmisc (version 4.0)

rotL: Rotation matrix

Description

Generate a square orthogonal rotation matrix for pre-multiplication.

Usage

rotL(phi,k=1,m=2,n=3)
  rotPz(P)

Arguments

n
Order of the square rotation matrix >= 2.
k,m
Integers describing the plane of rotation, i.e. 1,2,3=x,y,z
phi
Real, angle of counter clockwise rotation in radian.
P
c(x,y,z), coordinates of projection point or projection direction P-Origin

Value

  • rotL: Matrix m for multiplication m%*%vector. rotPz: rotation matrix for $(0,0,zz)' = r * (x,y,z)'$. rotaP: rotation matrix around axis (P - Orig, Orig = c(0,0,0)).

Examples

Run this code
par(mfrow=c(2,4))
  x<- -20:20;Data <- matrix(c(x^2*10,(x^2-10*x)*4,(x+10)*1.5),ncol=3)
##  Data <- matrix(c(rnorm(99)*10,rnorm(99)*4,rnorm(99)*1.5),ncol=3)
  lim <- range(c(Data,-Data))*1.5
  RD <- Data  RD2 <- RD  RD3 <- RD2  plot(Data[,-3],xlim=lim,ylim=lim,xlab="x",ylab="y",pty="s")
  plot(RD[,-3],xlim=lim,ylim=lim,xlab="RD x",ylab="y",pty="s",pch=5,col="red")
  plot(RD2[,-3],xlim=lim,ylim=lim,xlab="RD2 x",ylab="y",pch=6,col="blue")
  plot(RD3[,-3],xlim=lim,ylim=lim,xlab="RD3 x",ylab="RD3 y",col="magenta")
  plot(Data[,1],RD3[,1])
  plot(Data[,2],RD3[,2])
  plot(Data[,3],RD3[,3])
  m <- rotL(pi/6,1,2)  m  eye <- c(0.5,2.5,4)
  re  <- rotPz(eye)
  round(rotaP(c(1,1,1),pi/1.5),2)
# [1,]    0    1    0  Permutation of axes 1 -> 2 -> 3 -> 1
# [2,]    0    0    1
# [3,]    1    0    0

Run the code above in your browser using DataLab