Let's make a disk class. The idea is that each disk will have a rotor which steps round a little bit with each time step. The root disk will be stationary. We can (optionally) connect a pencil and/or a child disk to the rotor. The edge of each disk and its child will remain in contact at a point, with no slip, meaning that the body of the child disk will be forced to rotate at an angular velocity determined by its parents angular velocity and the ratio of their radiuses. A child disk can be either on the inside or the outside of its parent.

Simulation will rely on two Disk methods. Increment advances time by one step, updating the rotor angle relative to the body. At the same time, we make the corresponding change to the child disk body angle. Finally, we call increment on the child disk so that the update propagates through the stack. After all the disks have updated their internal state, we record their absolute positions using emit_position. This calculates the position of the disk and writes it into a store object, which has been passed to all disks. Since the absolute position of each disk depends on that of its parent, calling emit_position on the last one will cause all of them to write to the store.