The Ptolemy machine