The Padovan sequence is a cousin of the more famous Fibonacci sequence defined by the initial values and the recurrence relation . That is, the next value is obtained not by summing the previous two values but by summing the two values before the last …
The Recamán sequence is a famous sequence invented by the Colombian mathematician, Bernardo Recamán Santos. It is defined by the following algorithm, starting at : if this number is positive and has not already appeared in the sequence; otherwise . It was covered in a …
To produce a children's sticker chart from a provided image, the following code divides it into squares (which can be cut out) and produces further images with matching labels for the reverse side of the printed image and a piece of card onto which the …
A previous blog post dealt with packing circles into a circle. To fill an arbitrary shape, a slightly different approach is needed. The code is presented in my github repo. A black-and-white PNG image should provided (the black areas to be filled). The ShapeFill class …
The following code attempts to pack a predefined number of smaller circles (of random radii between two given limits) into a larger one. The algorithm simply selects a random set of radii, sorts them into decreasing order (so the larger circles get placed first), and …
Truchet Tiles are decorated squares which can tile a plane to create a pattern. For example, the four tiles: can be placed at random orientations to yield a non-repeating pattern: Similarly the two types of tile consisting of two quarter-circles in diagonally-opposite vertices of a …
A Moiré pattern is an interference pattern that occurs when two grids of repeating lines or shapes are rotated by a small amount relative to one another (oblig. xkcd). A recent application concerned the experimental verification of Hofstadter's butterfly: Douglas Hofstadter (he of Gödel, Escher, …
The Ebbinghaus illusion is a famous visual effect based on the perception of the relative size. Two circles of the same size are surrounded in one case by obviously larger circles and in the other by obviously smaller circles. The former is perceived as being …
The Reutersvärd Triangle is an example of an impossible object: a two-dimensional optical illusion perceived as a projection of a three-dimensional object that cannot exist. The Python code below creates an SVG image of Reutersvärd's impossible triangular arrangement of cubes, similar to the more famous …
Here is a short Python program to visualize the table of multiplication modulo . The integers and number the rows and columns of the image plot produced. and are supplied as command line arguments (if is not supplied, it defaults to ). This code is …