Debian Codegraph @

man/rot2.Rd

raw
1 \name{rot2}
2 %no longer \encoding{latin1}% "^o" (degree) below
3 \alias{rot2}
4 \title{Rotate Planar Points by Angle}
5 \description{
6 Rotate planar (xy) points by angle \code{phi} (in radians).
7 }
8 \usage{
9 rot2(xy, phi)
10 }
11 \arguments{
12 \item{xy}{numeric 2-column matrix, or coercable to one.}
13 \item{phi}{numeric scalar, the angle in radians (i.e., \code{phi=pi}
14 corresponds to 180 degrees) by which to rotate the points.}
15 }
16 \value{
17 A two column matrix as \code{xy}, containing the rotated points.
18 }
19 \author{Martin Maechler, Oct.1994}
20 \examples{
21 ## Rotate three points by 60 degrees :
22 (xy0 <- rbind(c(1,0.5), c(1,1), c(0,1)))
23 (Txy <- rot2(xy0, phi = 60 * pi/180))
24 plot(xy0, col = 2, type = "b", asp = 1,
25 xlim=c(-1,1), ylim=c(0,1.5), main = "rot2(*, pi/3) : 2d rotation by 60°")
26 points(Txy, col = 3, type = "b")
27 O <- rep(0,2); P2 <- rbind(xy0[2,], Txy[2,])
28 arrows(O,O,P2[,1],P2[,2], col = "dark gray")
29
30 xy0 <- .8*rbind(c(1,0), c(.5,.6), c(.7,1), c(1,1), c(.9,.8), c(1,0)) - 0.2
31 plot(xy0, col= 2, type="b", main= "rot2( <polygon>, pi/4 * 1:7)", asp=1,
32 xlim=c(-1,1),ylim=c(-1,1), lwd= 2, axes = FALSE, xlab="", ylab="")
33 abline(h=0, v=0, col="thistle"); text(1.05, -.05, "x"); text(-.05,1.05, "y")
34 for(phi in pi/4 * 0:7)
35 do.call("arrows",c(list(0,0),rot2(xy0[2,], phi), length=0.1, col="gray40"))
36 for(phi in pi/4 * 1:7)
37 polygon(rot2(xy0, phi = phi), col = 1+phi/(pi/4), border=2, type = "b")
38 }
39 \keyword{manip}
40 \keyword{math}