| vectors3d | R Documentation | 
This function draws vectors in a 3D plot, in a way that facilitates constructing vector diagrams. It allows vectors to be specified as rows of a matrix, and can draw labels on the vectors.
vectors3d(
  X,
  origin = c(0, 0, 0),
  headlength = 0.035,
  ref.length = NULL,
  radius = 1/60,
  labels = TRUE,
  cex.lab = 1.2,
  adj.lab = 0.5,
  frac.lab = 1.1,
  draw = TRUE,
  ...
)
| X | a vector or three-column matrix representing a set of geometric vectors; if a matrix, one vector is drawn for each row | 
| origin | the origin from which they are drawn, a vector of length 3. | 
| headlength | the  | 
| ref.length | vector length to be used in scaling arrow heads so that they are all the same size; if  | 
| radius | radius of the base of the arrow heads | 
| labels | a logical or a character vector of labels for the vectors. If  | 
| cex.lab | character expansion applied to vector labels. May be a number or numeric vector corresponding to the the
rows of  | 
| adj.lab | label position relative to the label point as in  | 
| frac.lab | location of label point, as a fraction of the distance between  | 
| draw | if  | 
| ... | other arguments passed on to graphics functions. | 
invisibly returns the vector ref.length used to scale arrow heads
At present, the color (color=) argument is not handled as expected when more than one vector is to be drawn.
Michael Friendly
arrows3d, texts3d, rgl.material
Other vector diagrams: 
Proj(),
arc(),
arrows3d(),
circle3d(),
corner(),
plot.regvec3d(),
pointOnLine(),
regvec3d(),
vectors()
vec <- rbind(diag(3), c(1,1,1))
rownames(vec) <- c("X", "Y", "Z", "J")
library(rgl)
open3d()
vectors3d(vec, color=c(rep("black",3), "red"), lwd=2)
# draw the XZ plane, whose equation is Y=0
planes3d(0, 0, 1, 0, col="gray", alpha=0.2)
vectors3d(c(1,1,0), col="green", lwd=2)
# 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)))
# show some orthogonal vectors
p1 <- c(0,0,0)
p2 <- c(1,1,0)
p3 <- c(1,1,1)
p4 <- c(1,0,0)
corner(p1, p2, p3, col="red")
corner(p1, p4, p2, col="red")
corner(p1, p4, p3, col="blue")
rgl.bringtotop()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.