rotation: Rotation

View source: R/rotation.R

rotationR Documentation

Rotation

Description

Rotates a set of points.

Usage

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, yrot

optional, x and 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)


KevCaz/graphicsutils documentation built on Sept. 16, 2022, 10:05 a.m.