Rotates a set of points.

rotation(x, y, rot = 90, xrot = mean(x), yrot = mean(y), rad = FALSE)

Arguments

x, y

x and y coordinates of points.

rot

angle of the rotation expressed in degree.

xrot

optional, x coordinate for the center of rotation.

yrot

optional, y coordinate for the center of rotation.

rad

logical. Should radian be used rather than degrees?

Details

Returns the coordinates of the points after rotation. If the coordinates of the rotation center are not specified, then the rotation center is the centroid of the points to be rotated.

Examples

plot0(c(0,10),c(0,10))
y <- c(6,6,9) x <- c(2,5,3.5) polygon(x, y, lwd=2)
myrot <- rotation(x, y, rot=90) polygon(myrot$x, myrot$y, lwd=2, border=4)
myrot2 <- rotation(x, y, rot=-40, 0, 0) polygon(myrot2$x,myrot2$y, lwd=2, border=3)