Last chance! 50% off unlimited learning
Sale ends in
rbind.traps
to
create complex geometries.flip (object, lr = F, tb = F, ...)
rotate (object, degrees, centrexy = NULL, ...)
shift (object, shiftxy, ...)
## S3 method for class 'traps':
flip(object, lr = F, tb = F, ...)
## S3 method for class 'traps':
rotate(object, degrees, centrexy = NULL, \dots)
## S3 method for class 'traps':
shift(object, shiftxy, \dots)
## S3 method for class 'popn':
flip(object, lr = F, tb = F, ...)
## S3 method for class 'popn':
rotate(object, degrees, centrexy = NULL, \dots)
## S3 method for class 'popn':
shift(object, shiftxy, \dots)
## S3 method for class 'mask':
shift(object, shiftxy, \dots)
flip
reflects points about a vertical or horizontal axis. Logical
values for lr
or tb
indicate that points should be flipped
about the mean on the relevant axis. Numeric values indicate the
particular axis value(s) about which points should be flipped. The
default arguments result in no change.
shift
shifts the location of each point by the desired amount
on each axis.
rotate
rotates the array about a designated point. If
centrexy
is NULL then rotation is about (0,0)
(rotate.default
), the array centre (rotate.traps
), or the
centre of the bounding box (rotate.popn
).traps
, popn
temp <- matrix(runif (20) * 2 - 1, nc = 2)
## flip
temp2 <- flip(temp, lr = 1)
plot(temp, xlim=c(-1.5,4), ylim = c(-1.5,1.5), pch = 16)
points (temp2, pch = 1)
arrows (temp[,1], temp[,2], temp2[,1], temp2[,2], length = 0.1)
abline(v = 1, lty = 2)
## rotate
temp2 <- rotate(temp, 25)
plot(temp, xlim=c(-1.5,1.5), ylim = c(-1.5,1.5), pch = 16)
points (0,0, pch=2)
points (temp2, pch = 1)
arrows (temp[,1], temp[,2], temp2[,1], temp2[,2], length = 0.1)
## shiftxy
temp2 <- shift(temp, c(0.1, 0.1))
plot(temp, xlim=c(-1.5,1.5), ylim = c(-1.5,1.5), pch = 16)
points (0,0, pch=2)
points (temp2, pch = 1)
arrows (temp[,1], temp[,2], temp2[,1], temp2[,2], length = 0.1)
## flip.traps
par(mfrow = c(1,2), xpd = TRUE)
traps1 <- make.grid(nx = 8, ny = 6, ID = "numxb")
traps2 <- flip (traps1, lr = TRUE)
plot(traps1, border = 5, label = TRUE, offset = 7, gridl = FALSE)
plot(traps2, border = 5, label = TRUE, offset = 7, gridl = FALSE)
par(mfrow = c(1,1), xpd = FALSE)
## rotate.traps
hollow1 <- make.grid(nx = 8, ny = 8, hollow = TRUE)
nested <- rbind (hollow1, rotate(hollow1, 45, c(70, 70)))
plot(nested, gridlines = FALSE)
## shift.traps
hollow1 <- make.grid(nx = 8, ny = 8, hollow = TRUE)
hollow2 <- shift(make.grid(nx = 6, ny = 6, hollow = TRUE), c(20, 20))
nested <- rbind (hollow1, hollow2)
plot(nested, gridlines = FALSE, label = TRUE)
Run the code above in your browser using DataLab