/* shrinking polygons, not rotated, with changing colour */ c : [black, red, blue, green, magenta, cyan, yellow]$ load('draw)$ draw2d(proportional_axes = 'xy, dimensions = [1024, 768], xrange = [-3,7], yrange = [-1,9], transparent = true, join(makelist(color=c[t], t, 1, 6), map(polygon, makelist( subst(t, t, [[t/2, t/2], [6 - t/2, t/2], [6 - t/2, 6 - t/2], [t/2, 6 - t/2]]), t, 0, 5))) ); /* single polygon, rotated around [0,0] by pi/4 (45 degrees), with changing colour */ c : [black, red, blue, green, magenta, cyan, yellow]$ g : [[-3, 0], [3, 6]]$ /* diagonal of rectangle */ [[x1, y1], [x2, y2]] : g$ g : [[x1, y1], [x2, y1], [x2, y2], [x1, y2]]$ kill(x1, y1, x2, y2)$ gPlot : []$ for j in g do ( /* iterate through co-ordinate-pairs in polygon() list */ [x, y] : j, r : sqrt(x^2 + y^2), /* polar radius (r) */ a : acos(x/r), /* polar angle (theta) */ gPlot: append(gPlot, [[float(cos(a + %pi/4)*r), float(sin(a + %pi/4)*r)]]) /* new [x, y] */ )$ gPlot : append([g], [gPlot])$ /* original box & modified box */ load('draw)$ draw2d(proportional_axes = 'xy, dimensions = [1024, 768], xrange = [-7,4], yrange = [-3,7], transparent = true, join(makelist(color=c[t], t, 1, 2), map(polygon, gPlot)) ); /* shrinking polygons, rotated around [3,3] by pi/12 (15 degrees), with changing colour */ c : [black, red, blue, green, magenta, cyan, yellow]$ gPlot : []$ for t : 0 thru 4 do ( g : [], h : subst(t, t, [[t/2, t/2], [6 - t/2, t/2], [6 - t/2, 6 - t/2], [t/2, 6 - t/2]]), A : matrix([float(cos(t*%pi/12)), float(sin(t*%pi/12))], [float(-sin(t*%pi/12)), float(cos(t*%pi/12))]), for j in h do ( R : matrix(j) - 3, /* subtract point of rotation [3, 3] */ /* '.' not '*' for sum-product multiplication, undo translate operation */ g : append(g, [list_matrix_entries(R.A + 3)]) ), gPlot : append(gPlot, [g]) /* original box & modified boxes */ )$ load('draw)$ draw2d(proportional_axes = 'xy, dimensions = [1024, 768], xrange = [-3,7], yrange = [-1,9], transparent = true, join(makelist(color=c[t], t, 1, 5), map(polygon, gPlot)) );