Compute a homothetic transformation for a set of points. The transformed set of points is optionally drawn as a polygon.

homothety(x, y, lambda, xcen = NULL, ycen = NULL, add = FALSE, ...)

Arguments

x

the x coordinates of points. It can also be a matrix (see details).

y

the y coordinates of points.

lambda

the factor to be used for the homothetetic transformations.

xcen

the x coordinate for the center of rotation.

ycen

the y coordinate for the center of rotation.

add

logical. If TRUE the set of transformed points are drawn as a polygon.

...

additional arguments to be passed to graphics::polygon() function (used only if add is TRUE).

Details

If x is a matrix with more than 2 columns, then x is the first column and y the second one.

Note that lambda, xcen and ycen are unique, meaning that homothety computes only one homothetic transformation. Drawing the points computed is relevant only if there are more than 2 points.

References

https://en.wikipedia.org/wiki/Homothetic_transformation.

Examples

# Example: plot0(c(0,10),c(0,10))
x <- c(4,6,5) y <- c(2,2,4) polygon(x,y)
poly2 <- homothety(x,y,2) polygon(poly2$x,poly2$y)
poly3 <- homothety(x, y, -2.5, xcen=5, ycen=4, border=4, add=TRUE)