rescale_polygon_list: Rescale a polygon_list object

rescale_polygon_listR Documentation

Rescale a polygon_list object

Description

Rescale a polygon_list object

Usage

rescale_polygon_list(
  polygon_list,
  rotate_degrees = 0,
  scale = c(1, 1),
  shift = c(0, 0),
  center = NULL,
  share_center = FALSE,
  share_polygon_center = TRUE,
  ...
)

Arguments

polygon_list

list object

rotate_degrees

numeric value in degrees indicating rotation around the center, where positive values are clockwise rotation. This rotation is only applied to two columns in x defined by rotation_axes.

scale

numeric vector whose values are expanded to length ncol(x). After subtracting the center, the coordinates in each column are multiplied by the scale.

shift

numeric vector whose values are expanded to length ncol(x). The coordinates in each column are added to the shift, after applying scale and rotate_degrees

center

numeric vector whose values are expanded to length ncol(x), indicating the center point used for scale and rotate_degrees transformations. When center=NULL it is derived from the bounding box, which is the mean of the range for each column in x.

share_center

logical indicating whether all polygons should share the same center, where share_center=TRUE will adjust everything collectively, and share_center=FALSE will adjust each polygon independently relative to its own center coordinate.

...

additional arguments are ignored.

Details

This function simply applies rescale_coordinates() to an list polygon_list object.

Value

object list polygon_list

See Also

Other venndir polygons: bbox_polygon_list(), eulerr_to_polygon_list(), get_largest_polygon_list(), get_venn_polygon_shapes(), intersect_polygon_list(), labelr_polygon_list(), minus_polygon_list(), nudge_polygon_coords(), nudge_polygon_list(), plot_polygon_list(), polygon_areas(), polygon_circles(), polygon_ellipses(), polygon_list_labelr(), polygon_list_to_xy_list(), simple_ellipse(), union_polygon_list(), xy_list_to_polygon_list()

Examples

polygon_list <- polygon_ellipses(c(3, 2), c(2, 3),
   xradius=c(1, 4),
   yradius=c(5, 2))
polygon_list1 <- intersect_polygon_list(polygon_list);
polygon_list2 <- minus_polygon_list(polygon_list[1:2]);
polygon_list3 <- minus_polygon_list(polygon_list[2:1]);
polygon_list123 <- c(polygon_list1,
   polygon_list2,
   polygon_list3);

polygon_list123a <- rescale_polygon_list(polygon_list123,
   scale=c(1.5, 1.5),
   share_center=TRUE);
polygon_list123b <- rescale_polygon_list(polygon_list123,
   scale=c(1.5, 1.5));
col3 <- c("#FF000077", "#FFDD0077", "#0000DD77");
par("mfrow"=c(2, 2));
plot_polygon_list(polygon_list123,
   col=col3,
   main="original polygons",
   xlim=c(-10, 15), ylim=c(-5, 10));
axis(1, las=2); axis(2, las=2);
plot_polygon_list(polygon_list123a,
   col=col3,
   main="share_center=TRUE",
   xlim=c(-10, 15), ylim=c(-5, 10));
axis(1, las=2); axis(2, las=2);
plot_polygon_list(polygon_list123[1:2],
   col=col3[1:2],
   main="share_center=FALSE\nrescaling only the blue polygon",
   xlim=c(-10, 15), ylim=c(-5, 10));
axis(1, las=2); axis(2, las=2);
plot_polygon_list(polygon_list123b[3],
   col=col3[3],
   add=TRUE);
plot_polygon_list(polygon_list123[2:3],
   col=col3[2:3],
   main="share_center=FALSE\nrescaling only the red polygon",
   xlim=c(-10, 15), ylim=c(-5, 10));
axis(1, las=2); axis(2, las=2);
plot_polygon_list(polygon_list123b[1],
   col=col3[1],
   add=TRUE);
par("mfrow"=c(1, 1));

{par("mfrow"=c(2, 2));
plot_polygon_list(polygon_list123, col=col3,
   xlim=c(-4, 8), ylim=c(-4, 8))
title(main="Original polygons", line=0);
plot_polygon_list(rescale_polygon_list(polygon_list123, rotate_degrees=c(`11`=45, `12`=-10)), col=col3,
   xlim=c(-4, 8), ylim=c(-4, 8))
title(sub="yellow +45 degrees\nblue -10 degrees", line=0,
   main="share_polygon_center=TRUE (default)")
plot_polygon_list(rescale_polygon_list(polygon_list123, rotate_degrees=c(`11`=45, `12`=-10), share_polygon_center=FALSE), col=col3,
   xlim=c(-4, 8), ylim=c(-4, 8))
title(sub="yellow +45 degrees\nblue -10 degrees", line=0,
   main="share_polygon_center=FALSE\n(each polygon uses its center)")
plot_polygon_list(rescale_polygon_list(polygon_list123, rotate_degrees=c(`11`=45, `12`=-10), share_center=TRUE), col=col3,
   xlim=c(-4, 8), ylim=c(-4, 8))
title(sub="yellow +45 degrees\nblue -10 degrees", line=0,
   main="share_center=TRUE\n(all polygons share one global center)")
par("mfrow"=c(1, 1));}



jmw86069/venndir documentation built on June 15, 2024, 1:52 p.m.