rescale_coordinates | R Documentation |
Scale, rotate, and shift numeric coordinates
rescale_coordinates(
x,
scale = c(1, 1),
rotate_degrees = 0,
shift = c(0, 0),
center = NULL,
rotation_axes = c(1, 2),
plot_debug = FALSE,
...
)
x |
|
scale |
|
rotate_degrees |
|
shift |
|
center |
|
rotation_axes |
|
plot_debug |
|
... |
additional arguments are ignored. |
This function takes a numeric matrix with two or more numeric columns, and adjusts the coordinates in three ways:
scale: adjust coordinate range by a multiplier, relative to a central point
rotate: rotate coordinates around a central point in degrees
shift: adjust coordinate range by adding a numeric value
The operations are performed in that order: rotate, scale, shift.
When center
is not defined, the default behavior is to use
the mean of the range of each coordinate column. Using the mean
range is equivalent to using the mean of the bounding box.
matrix
with numeric
values after processing.
Other venndir spatial:
degrees_to_adj()
,
diff_degrees()
,
display_angles()
,
mean_degree_arc()
,
mean_degrees()
,
spread_degrees()
pts <- matrix(ncol=2, c(1:4, 6, 8, 5, 7));
rownames(pts) <- letters[1:4];
plot(pts, pch=rownames(pts), asp=1)
points(pts, pch=21, cex=3)
pts2 <- rescale_coordinates(pts, rotate_degrees=25);
arrows(x0=pts[,1], x1=pts2[,1], y0=pts[,2], y1=pts2[,2], col="red")
points(pts2, pch=21, cex=3, col="red", bg="white")
points(pts2, pch=rownames(pts), col="red")
pts3 <- rescale_coordinates(pts2, scale=0.5);
arrows(x0=pts2[,1], x1=pts3[,1], y0=pts2[,2], y1=pts3[,2], col="blue")
points(pts3, pch=21, cex=3, col="blue", bg="white")
points(pts3, pch=rownames(pts), col="blue")
pts4 <- rescale_coordinates(pts3, shift=c(0.5, 0.5));
arrows(x0=pts3[,1], x1=pts4[,1], y0=pts3[,2], y1=pts4[,2], col="gold")
points(pts4, pch=21, cex=3, col="gold", bg="white")
points(pts4, pch=rownames(pts), col="gold")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.