ARC

Description A utility function for drawing vector diagrams. Draws a circular arc to show the angle between two vectors in 2D or 3D.

Usage arc(p1, p2, p3, d = 0.1, absolute = TRUE, …)

Arguments p1 : Starting point of first vector p2 : End point of first vector, and also start of second vector p3 : End point of second vector

d : The distance from p2 along each vector for drawing their corner

absolute : logical; if TRUE, d is taken as an absolute distance along the vectors; otherwise it is calculated as a relative distance, i.e., a fraction of the length of the vectors.

… : Arguments passed to link[graphics]{lines} or to link[rgl]{lines3d}

Details In this implementation, the two vectors are specified by three points, p1, p2, p3, meaning a line from p1 to p2, and another line from p2 to p3.

library(rgl)
vec <- rbind(diag(3), c(1,1,1))
vec
##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]    0    1    0
## [3,]    0    0    1
## [4,]    1    1    1
rownames(vec) <- c("X", "Y", "Z", "J")
open3d()
## wgl 
##   1
aspect3d("iso")

# draw the XZ plane, whose equation is Y=0
planes3d(0, 0, 1, 0, col="gray", alpha=0.2)
planes3d
## function (a, b = NULL, c = NULL, d = 0, ...) 
## {
##     .check3d()
##     save <- material3d()
##     on.exit(material3d(save))
##     list(a = a, b = b, c = c, d = d)
##     do.call("rgl.material0", .fixMaterialArgs(..., Params = save))
##     normals <- rgl.vertex(a, b, c)
##     nnormals <- rgl.nvertex(normals)
##     noffsets <- length(d)
##     if (nnormals && noffsets) {
##         idata <- as.integer(c(nnormals, noffsets))
##         ret <- .C(rgl_planes, success = as.integer(FALSE), idata, 
##             as.numeric(normals), as.numeric(d), NAOK = TRUE)
##         if (!ret$success) 
##             stop("'rgl_planes' failed")
##         lowlevel(ret$success)
##     }
## }
## <bytecode: 0x000001ed6d4be180>
## <environment: namespace:rgl>
# show projections of the unit vector J
segments3d(rbind( c(1,1,1), c(1, 1, 0)))
segments3d(rbind( c(0,0,0), c(1, 1, 0)))
segments3d(rbind( c(1,0,0), c(1, 1, 0)))
segments3d(rbind( c(0,1,0), c(1, 1, 0)))
segments3d(rbind( c(1,1,1), c(1, 0, 0)))
segments3d
## function (x, y = NULL, z = NULL, ...) 
## {
##     .check3d()
##     save <- material3d()
##     on.exit(material3d(save))
##     do.call("rgl.primitive0", c(list(type = "lines", x = x, y = y, 
##         z = z), .fixMaterialArgs(..., Params = save)))
## }
## <bytecode: 0x000001ed6ea5bdd8>
## <environment: namespace:rgl>
# show some orthogonal vectors
p1 <- c(0,0,0)
p2 <- c(1,1,0)
p3 <- c(1,1,1)
p4 <- c(1,0,0)
p1
## [1] 0 0 0
p2
## [1] 1 1 0
p3
## [1] 1 1 1
p4
## [1] 1 0 0

3D arrows

Description Draws nice 3D arrows with cone3ds at their tips.

Usage arrows3d( coords, headlength = 0.035, head = “end”, scale = NULL, radius = NULL, ref.length = NULL, draw = TRUE, … )

Arguments

coords : A 2n x 3 matrix giving the start and end (x,y,z) coordinates of n arrows, in pairs. The first vector in each pair is taken as the starting coordinates of the arrow, the second as the end coordinates.

headlength : Length of the arrow heads, in device units

head : Position of the arrow head. Only head=“end” is presently implemented.

scale : Scale factor for base and tip of arrow head, a vector of length 3, giving relative scale factors for X, Y, Z

radius :radius of the base of the arrow head

ref.length : length of vector to be used to scale all of the arrow heads (permits drawing arrow heads of the same size as in a previous call); if NULL, arrows are scaled relative to the longest vector

draw : if TRUE (the default) draw the arrow(s)

… : rgl arguments passed down to segments3d and cone3d, for example, col and lwd

Details This function is meant to be analogous to arrows, but for 3D plots using rgl. headlength, scale and radius set the length, scale factor and base radius of the arrow head, a 3D cone. The units of these are all in terms of the ranges of the current rgl 3D scene.

Value invisibly returns the length of the vector used to scale the arrow heads

Author(s) January Weiner, borrowed from the pca3d package, slightly modified by John Fox

See Also vectors3d Other vector diagrams: Proj(), arc(), circle3d(), corner(), plot.regvec3d(), pointOnLine(), regvec3d(), vectors3d(), vectors()

BUILDTMAT

Description Recover the history of the row operations that have been performed. This function combines the transformation matrices into a single transformation matrix representing all row operations or may optionally print all the individual operations which have been performed.

Usage buildTmat(x, all = FALSE) ## S3 method for class ‘trace’ as.matrix(x, …) ## S3 method for class ‘trace’ print(x, …)

Arguments x : a matrix A, joined with a vector of constants, b, that has been passed to gaussianElimination or the row operator matrix functions all : logical; print individual transformation ies?

… : additional arguments

Value the transformation matrix or a list of individual transformation matrices

Author(s) Phil Chalmers

See Also echelon, gaussianElimination

#Examples
A <- matrix(c(2, 1, -1,
-3, -1, 2,
-2, 1, 2), 3, 3, byrow=TRUE)
b <- c(8, -11, -3)
# using row operations to reduce below diagonal to 0
Abt <- Ab <- cbind(A, b)
Abt
##                 b
## [1,]  2  1 -1   8
## [2,] -3 -1  2 -11
## [3,] -2  1  2  -3