The compass, a crucial navigational tool, originated in ancient China around the 4th century BC, initially used for divination and geomancy, later adopted for navigation, and spread to Europe and the Islamic world. 

Here's a more detailed look at the compass's history:

Early Chinese Compass:

The earliest compasses were made from lodestone (a naturally magnetized iron ore) shaped like a spoon or ladle and placed on a flat, square-shaped plate. 

These were used for divination, geomancy (finding auspicious locations), and later, navigation. 

The Chinese called the compass a "south pointer". 

From Divination to Navigation:

Initially, compasses were used for spiritual purposes, not for navigation. 

Over time, Chinese sailors and explorers realized the compass's potential for navigation, especially during the Song Dynasty (10th-13th centuries). 

The Song Dynasty saw the development of navigational compasses with lodestone needles floating in water, which were more accurate for maritime use. 

Spread to Europe and the Islamic World:

The compass traveled to Europe and the Islamic world through trade routes. 

The first recorded use of a compass in Europe is around 1187-1202. 

In the Islamic world, compasses were used for navigation, astronomy, and as a "Qibla indicator" (to find the direction of Mecca for prayer). 

Further Developments:

Over time, various improvements were made to the compass, including the development of dry compasses and liquid compasses. 

In 1745, Gowin Knight developed a method of magnetizing steel that retained its magnetization for long periods, leading to more durable compass needles. 

The geometric and military compass of Galileo (1564-1642) belonged to this class of instruments. Invented in Padua in 1597, the instrument is also linked to Galileo's activity in the Accademia Delia, founded in Padua to provide mathematical instruction for young noblemen training for a military career. 

Modern Compasses:

Modern compasses still use the same basic principle as their ancient predecessors, but they are made from more modern materials and have incorporated advanced improvements. 

Magnetized needles or dials are placed inside a capsule filled with liquid, and the casing is often transparent for use on maps.