Thursday, January 31, 2019

Farey Sequences and Ford Circles in JavaScript


Like the phyllotaxis spiral, a nice mathematical figure to draw in code is the sequence of Ford Circles.

A while back I tried generating these using Fathom and Processing - now for fun I've tried them in JavaScript. A page to play with them is here, and the source code is in a Github repo.

On the page, you can control the level of the Farey sequence used to generate the circles - you start off with just 0 and 1:


Using the buttons provided, you can increase the number of terms in the sequence and the corresponding number of circles.


After a certain point, the page does not list the entire sequence associated with the circles.