In [1]:
library('sf')
Linking to GEOS 3.6.2, GDAL 2.2.3, proj.4 4.9.3
In [3]:
## rocker_geospatial_sf/demo/affine.R

a = 0.95
b = 0.8
ang = 3 * pi / 180
rot = function(a) matrix(c(cos(a), sin(a), -sin(a), cos(a)), 2, 2)
n = 12
drift = c(.12, .07)

outer = rbind(c(-1,-1), c(1, -1), c(1, 1), c(-1, 1), c(-1, -1))
hole = a * outer[5:1,]

# only shift:
p = st_sfc(lapply(0:n, 
	function(i) { st_polygon(list(outer, hole)) * rot(0) * b^i + drift * i * b ^ i } ))
plot(p, col = grey(0:n/n), border = 0)

# shift + rotate:
p = st_sfc(lapply(0:n, 
	function(i) { st_polygon(list(outer, hole)) * rot(i * ang) * b ^ i + drift * i * b ^ i } ))
p
plot(p, col = grey(0:n/n), border = 0)
g = st_geometrycollection(p)
plot(g)
mp = st_multipolygon(p)
opar = par(mfrow = c(2,2), mar = rep(0,4))
plot(mp * rot(10))
plot(mp * rot(20))
plot(mp * rot(30))
plot(mp * rot(40))
par(opar)
POLYGON ((-1 -1, 1 -1, 1 1, -1 1, -1 -1), (-0.9...
POLYGON ((-0.7447724 -0.7010349, 0.8530349 -0.7...
POLYGON ((-0.5497922 -0.4799958, 0.7231958 -0.6...
POLYGON ((-0.4014709 -0.318082, 0.609922 -0.478...
POLYGON ((-0.2892019 -0.2008006, 0.5120966 -0.3...
Geometry set for 13 features 
geometry type:  POLYGON
dimension:      XY
bbox:           xmin: -1 ymin: -1 xmax: 1 ymax: 1
epsg (SRID):    NA
proj4string:    NA
First 5 geometries: