A compass needle is a permanent magnet, which itself reacts to the permanent magnet in the earth's axis. Unfortunately, the fields of permanent magnets are very hard to calculate, and require an understanding of complex ferromagnetic phenomena, belonging as much to atomic theory as to electromagnetism.