arc: Draw an arc showing the angle between vectors

Description Usage Arguments Details Value References See Also Examples

View source: R/corner.R

Description

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

Usage

1
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.

Value

none

References

http://math.stackexchange.com/questions/1507248/find-arc-between-two-tips-of-vectors-in-3d

See Also

Other vector diagrams: Proj, arrows3d, corner, plot.regvec3d, pointOnLine, regvec3d, vectors3d, vectors

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library(rgl)
vec <- rbind(diag(3), c(1,1,1))
rownames(vec) <- c("X", "Y", "Z", "J")
open3d()
aspect3d("iso")
vectors3d(vec, col=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)
# 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)))

# show some orthogonal vectors
p1 <- c(0,0,0)
p2 <- c(1,1,0)
p3 <- c(1,1,1)
p4 <- c(1,0,0)
# show some angles
arc(p1, p2, p3, d=.2)
arc(p4, p1, p2, d=.2)
arc(p3, p1, p2, d=.2)

matlib documentation built on April 4, 2018, 5:03 p.m.