R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("orientlib-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('orientlib') Loading required package: scatterplot3d > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "boat3d" > > ### * boat3d > > flush(stderr()); flush(stdout()) > > ### Name: boat3d > ### Title: Draw boat glyphs for orientation data > ### Aliases: boat3d > ### Keywords: hplot dynamic > > ### ** Examples > > x <- eulerzyx(psi=c(0,pi/4,0,0), theta=c(0,0,pi/4,0), phi=c(0,0,0,pi/4)) > > # Need a 3D renderer; assume scatterplot3d, but others could be used > > s <- boat3d(x, 0:3, axes = FALSE, graphics = 'scatterplot3d') > text(s$xyz.convert(0:3, rep(-0.5,4), rep(-0.5,4)), + label = c('Id','z','y','x')) > > ## Not run: > ##D > ##D # if the djmrgl package is loaded, this code will work > ##D > ##D boat3d(x, 0:3, axes = FALSE) > ##D axis3d('yz',at=0:3,labels=c('Id','z','y','x')) > ##D > ##D # if the rgl package is loaded, this code will work > ##D > ##D boat3d(x, 0:3, axes = FALSE, graphics = 'rgl') > ##D rgl.bbox(xat=0:3,xlab=c('Id','z','y','x'),yat=1,zat=1,color='grey') > ## End(Not run) > > > > cleanEx(); ..nameEx <- "eulerzxz" > > ### * eulerzxz > > flush(stderr()); flush(stdout()) > > ### Name: eulerzxz > ### Title: Create an orientation using Euler angles > ### Aliases: eulerzxz eulerzxz,orientation,missing,missing-method > ### Keywords: array algebra > > ### ** Examples > > x <- eulerzxz(c(1,0,0), c(0,1,0), c(0,0,1)) > x An object of class "eulerzxz" Slot "x": phi theta psi [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 > rotmatrix(x) An object of class "rotmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] 0.5403023 0.8414710 0 [2,] -0.8414710 0.5403023 0 [3,] 0.0000000 0.0000000 1 , , 2 [,1] [,2] [,3] [1,] 1 0.0000000 0.0000000 [2,] 0 0.5403023 0.8414710 [3,] 0 -0.8414710 0.5403023 , , 3 [,1] [,2] [,3] [1,] 0.5403023 0.8414710 0 [2,] -0.8414710 0.5403023 0 [3,] 0.0000000 0.0000000 1 > > > > cleanEx(); ..nameEx <- "eulerzyx" > > ### * eulerzyx > > flush(stderr()); flush(stdout()) > > ### Name: eulerzyx > ### Title: Create an orientation using Euler angles > ### Aliases: eulerzyx eulerzyx,orientation,missing,missing-method > ### Keywords: array algebra > > ### ** Examples > > x <- eulerzyx(c(1,0,0), c(0,1,0), c(0,0,1)) > x An object of class "eulerzyx" Slot "x": psi theta phi [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 > rotmatrix(x) An object of class "rotmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] 0.5403023 0.8414710 0 [2,] -0.8414710 0.5403023 0 [3,] 0.0000000 0.0000000 1 , , 2 [,1] [,2] [,3] [1,] 0.5403023 0 -0.8414710 [2,] 0.0000000 1 0.0000000 [3,] 0.8414710 0 0.5403023 , , 3 [,1] [,2] [,3] [1,] 1 0.0000000 0.0000000 [2,] 0 0.5403023 0.8414710 [3,] 0 -0.8414710 0.5403023 > > > > cleanEx(); ..nameEx <- "matrix-classes" > > ### * matrix-classes > > flush(stderr()); flush(stdout()) > > ### Name: matrix-classes > ### Title: Matrix orientation classes > ### Aliases: matrix-classes rotmatrix-class skewmatrix-class > ### Keywords: classes > > ### ** Examples > > x <- rotmatrix(matrix(c(1,0,0, 0,1,0, 0,0,1), 3, 3)) > x An object of class "rotmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 > skewmatrix(x) An object of class "skewmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] 0 0 0 [2,] 0 0 0 [3,] 0 0 0 > > > > cleanEx(); ..nameEx <- "nearest" > > ### * nearest > > flush(stderr()); flush(stdout()) > > ### Name: nearest > ### Title: Find nearest SO(3) or orthogonal matrix. > ### Aliases: nearest.SO3 nearest.orthog > ### Keywords: array algebra > > ### ** Examples > > x <- matrix(rnorm(9), 3,3) > nearest.orthog(x) , , 1 [,1] [,2] [,3] [1,] -0.5106337 0.8432793 0.1677297 [2,] 0.4672670 0.1084208 0.8774431 [3,] -0.7217442 -0.5264266 0.4493999 > nearest.SO3(x) An object of class "rotmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] -0.1170527 0.7968831 0.5926853 [2,] -0.8190445 0.2600539 -0.5114079 [3,] -0.5616625 -0.5452974 0.6222428 > x <- -x > nearest.orthog(x) , , 1 [,1] [,2] [,3] [1,] 0.5106337 -0.8432793 -0.1677297 [2,] -0.4672670 -0.1084208 -0.8774431 [3,] 0.7217442 0.5264266 -0.4493999 > nearest.SO3(x) An object of class "rotmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] 0.5106337 -0.8432793 -0.1677297 [2,] -0.4672670 -0.1084208 -0.8774431 [3,] 0.7217442 0.5264266 -0.4493999 > > > > cleanEx(); ..nameEx <- "orientation-class" > > ### * orientation-class > > flush(stderr()); flush(stdout()) > > ### Name: orientation-class > ### Title: Class "orientation" > ### Aliases: orientation-class orientation > ### Keywords: classes > > ### ** Examples > > x <- rotmatrix(diag(3)) > x An object of class "rotmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 > rotvector(x) An object of class "rotvector" Slot "x": [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [1,] 1 0 0 0 1 0 0 0 1 > eulerzyx(x) An object of class "eulerzyx" Slot "x": psi theta phi [1,] 0 0 0 > eulerzxz(x) An object of class "eulerzxz" Slot "x": phi theta psi [1,] 0 0 0 > quaternion(x) An object of class "quaternion" Slot "x": q1 q2 q3 q4 [1,] 0 0 0 1 > > > > cleanEx(); ..nameEx <- "orientlm" > > ### * orientlm > > flush(stderr()); flush(stdout()) > > ### Name: orientlm > ### Title: Linear models for orientation data > ### Aliases: orientlm > ### Keywords: regression > > ### ** Examples > > x <- rep(1:10,10) > y <- rep(1:10,each=10) > A1 <- skewvector(cbind(x/10,y/10,rep(0,100))) > A2 <- skewvector(c(1,1,1)) > trueorientation <- skewvector(matrix(rnorm(300),100)) > noise <- skewvector(matrix(rnorm(300)/10,100)) > obs <- t(A1) %*% trueorientation %*% A2 %*% noise > > fit <- orientlm(obs, ~ x + y, trueorientation, ~ 1) Warning in is.na(rows) : is.na() applied to non-(list or vector) Warning in is.na(rows) : is.na() applied to non-(list or vector) > > context <- boat3d(A1, x, z=y, col = 'green', graphics='scatterplot3d') > boat3d(fit$A1, x, z=y, add=context) > > > > cleanEx(); ..nameEx <- "quaternion" > > ### * quaternion > > flush(stderr()); flush(stdout()) > > ### Name: quaternion > ### Title: Create an orientation using quaternions > ### Aliases: quaternion quaternion,orientation-method > ### Keywords: array algebra > > ### ** Examples > > x <- quaternion(c(1,0,0,0)) > x An object of class "quaternion" Slot "x": [,1] [,2] [,3] [,4] [1,] 1 0 0 0 > rotmatrix(x) An object of class "rotmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 -1 0 [3,] 0 0 -1 > > > > cleanEx(); ..nameEx <- "rotation.distance" > > ### * rotation.distance > > flush(stderr()); flush(stdout()) > > ### Name: rotation.distance > ### Title: Rotation angle or distance > ### Aliases: rotation.distance rotation.angle > ### Keywords: array algebra > > ### ** Examples > > rotation.angle(eulerzyx(1,0,0)) [1] 1 > rotation.distance(eulerzyx(1,0,0), eulerzyx(0,1,0)) [1] 1.383436 > > > > > cleanEx(); ..nameEx <- "rotmatrix" > > ### * rotmatrix > > flush(stderr()); flush(stdout()) > > ### Name: rotmatrix > ### Title: Create an orientation using Euler angles > ### Aliases: rotmatrix rotmatrix,orientation-method > ### Keywords: array algebra > > ### ** Examples > > x <- rotmatrix(matrix(c(1,0,0, 0,1,0, 0,0,1), 3, 3)) > x An object of class "rotmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 > > > > cleanEx(); ..nameEx <- "rotvector" > > ### * rotvector > > flush(stderr()); flush(stdout()) > > ### Name: rotvector > ### Title: Create an orientation using vectorized 3x3 matrices > ### Aliases: rotvector rotvector,orientation-method > ### Keywords: array algebra > > ### ** Examples > > x <- rotvector(c(0,1,0,-1,0,0,0,0,1)) > x An object of class "rotvector" Slot "x": [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [1,] 0 1 0 -1 0 0 0 0 1 > rotmatrix(x) An object of class "rotmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] 0 -1 0 [2,] 1 0 0 [3,] 0 0 1 > > > > cleanEx(); ..nameEx <- "skewmatrix" > > ### * skewmatrix > > flush(stderr()); flush(stdout()) > > ### Name: skewmatrix > ### Title: Create an orientation using the entries in a skew-symmetric > ### matrix representation > ### Aliases: skewmatrix skewmatrix,orientation-method > ### Keywords: array algebra > > ### ** Examples > > x <- skewmatrix(matrix(c(0,1,2,-1,0,3,-2,-3,0),3,3)) > x An object of class "skewmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] 0 -1 -2 [2,] 1 0 -3 [3,] 2 3 0 > rotmatrix(x) An object of class "rotmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] 0.34810748 -0.6313497 0.6929782 [2,] -0.93319235 -0.3037850 0.1920070 [3,] 0.08929286 -0.7135210 -0.6949206 > skewvector(x) An object of class "skewvector" Slot "x": [,1] [,2] [,3] [1,] -3 2 -1 > rotation.angle(x) [1] 2.541528 > > > > cleanEx(); ..nameEx <- "skewvector" > > ### * skewvector > > flush(stderr()); flush(stdout()) > > ### Name: skewvector > ### Title: Create an orientation using the entries in a skew-symmetric > ### matrix representation > ### Aliases: skewvector skewvector,orientation-method > ### Keywords: array algebra > > ### ** Examples > > x <- skewvector(c(1,0,0)) > x An object of class "skewvector" Slot "x": [,1] [,2] [,3] [1,] 1 0 0 > rotmatrix(x) An object of class "rotmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] 1 0.0000000 0.0000000 [2,] 0 0.5403023 0.8414710 [3,] 0 -0.8414710 0.5403023 > rotation.angle(x) [1] 1 > > > > cleanEx(); ..nameEx <- "vector-classes" > > ### * vector-classes > > flush(stderr()); flush(stdout()) > > ### Name: vector-classes > ### Title: Orientation classes > ### Aliases: eulerzyx-class eulerzxz-class rotvector-class quaternion-class > ### skewvector-class vector-classes > ### Keywords: classes > > ### ** Examples > > x <- eulerzyx(0,pi/4,0) > x An object of class "eulerzyx" Slot "x": psi theta phi [1,] 0 0.7853982 0 > eulerzxz(x) An object of class "eulerzxz" Slot "x": phi theta psi [1,] 1.570796 0.7853982 -1.570796 > rotmatrix(x) An object of class "rotmatrix" Slot "x": , , 1 [,1] [,2] [,3] [1,] 0.7071068 0 -0.7071068 [2,] 0.0000000 1 0.0000000 [3,] 0.7071068 0 0.7071068 > rotvector(x) An object of class "rotvector" Slot "x": [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [1,] 0.7071068 0 0.7071068 0 1 0 -0.7071068 0 0.7071068 > quaternion(x) An object of class "quaternion" Slot "x": q1 q2 q3 q4 [1,] 0 0.3826834 0 0.9238795 > skewvector(x) An object of class "skewvector" Slot "x": [,1] [,2] [,3] [1,] 0 0.7853982 0 > > > > ### *