Learn R Programming

DescTools (version 0.99.57)

GeomTrans: Geometric Transformations

Description

This function transforms geometric structures by translating, scaling and/or rotating them.

Usage

GeomTrans(x, y = NULL, trans = 0, scale = 1, theta = 0)

Value

The function invisibly returns a list of the coordinates for the transformed shape(s).

Arguments

x, y

vectors containing the coordinates of the vertices of the polygon , which has to be transformed. The coordinates can be passed in a plotting structure (a list with x and y components), a two-column matrix, .... See xy.coords.

trans

a vector of two values for the translation in x-, resp. y-direction. If only one value is supplied it will be recycled.

scale

a vector of two values for the scaling factor in x-, resp. y-direction. If only one value is supplied it will be recycled.

theta

angle of the rotation in radians starting from 3 o'clock counterclockwise.

Author

Andri Signorell <andri@signorell.net>

See Also

polygon, DrawRegPolygon, DrawEllipse, DrawArc

Examples

Run this code
# let's have a triangle
Canvas(main="Rotation")
x <- DrawRegPolygon(nv=3)[[1]]

xt <- GeomTrans(x, trans=c(1, 3), scale=c(2, 2), theta=pi/4)
polygon(xt)

Run the code above in your browser using DataLab