The mechanism of the avian magnetic compass