A compass is a device that shows the cardinal directions used for navigation and geographic orientation. It commonly consists of a magnetized needle or other element, such as a compass card or compass rose, which can pivot to align itself with magnetic north. Other methods may be used, including gyroscopes, magnetometers, and GPS receivers.
Compasses often show angles in degrees: north corresponds to 0°, and the angles increase clockwise, so east is 90°, south is 180°, and west is 270°. These numbers allow the compass to show azimuths or bearings which are commonly stated in degrees. If local variation between magnetic north and true north is known, then direction of magnetic north also gives direction of true north.
Among the Four Great Inventions, the magnetic compass was first invented as a device for divination as early as the Chinese Han Dynasty (since c. 206 BC),   and later adopted for navigation by the Song Dynasty Chinese during the 11th century.    The first usage of a compass recorded in Western Europe and the Islamic world occurred around 1190.  
The magnetic compass is the most familiar compass type. It functions as a pointer to " magnetic north", the local magnetic meridian, because the magnetized needle at its heart aligns itself with the horizontal component of the Earth's magnetic field. The magnetic field exerts a torque on the needle, pulling the North end or pole of the needle approximately toward the Earth's North magnetic pole, and pulling the other toward the Earth's South magnetic pole.  The needle is mounted on a low-friction pivot point, in better compasses a jewel bearing, so it can turn easily. When the compass is held level, the needle turns until, after a few seconds to allow oscillations to die out, it settles into its equilibrium orientation.
In navigation, directions on maps are usually expressed with reference to geographical or true north, the direction toward the Geographical North Pole, the rotation axis of the Earth. Depending on where the compass is located on the surface of the Earth the angle between true north and magnetic north, called magnetic declination can vary widely with geographic location. The local magnetic declination is given on most maps, to allow the map to be oriented with a compass parallel to true north. The locations of the Earth's magnetic poles slowly change with time, which is referred to as geomagnetic secular variation. The effect of this means a map with the latest declination information should be used.  Some magnetic compasses include means to manually compensate for the magnetic declination, so that the compass shows true directions.
There are other ways to find north than the use of magnetism, and from a navigational point of view a total of seven possible ways exist  (where magnetism is one of the seven). Two sensors that use two of the remaining six principles are often also called compasses, i.e. the gyrocompass and GPS-compass.
A gyrocompass is similar to a gyroscope. It is a non-magnetic compass that finds true north by using an (electrically powered) fast-spinning wheel and friction forces in order to exploit the rotation of the Earth. Gyrocompasses are widely used on ships. They have two main advantages over magnetic compasses:
Large ships typically rely on a gyrocompass, using the magnetic compass only as a backup. Increasingly, electronic fluxgate compasses are used on smaller vessels. However, magnetic compasses are still widely in use as they can be small, use simple reliable technology, are comparatively cheap, are often easier to use than GPS, require no energy supply, and unlike GPS, are not affected by objects, e.g. trees, that can block the reception of electronic signals.
GPS receivers using two or more antennae mounted separately and blending the data with an inertial motion unit (IMU) can now achieve 0.02° in heading accuracy and have startup times in seconds rather than hours for gyrocompass systems. The devices accurately determine the positions (latitudes, longitudes and altitude) of the antennae on the Earth, from which the cardinal directions can be calculated. Manufactured primarily for maritime and aviation applications, they can also detect pitch and roll of ships. Small, portable GPS receivers with only a single antenna can also determine directions if they are being moved, even if only at walking pace. By accurately determining its position on the Earth at times a few seconds apart, the device can calculate its speed and the true bearing (relative to true north) of its direction of motion. Frequently, it is preferable to measure the direction in which a vehicle is actually moving, rather than its heading, i.e. the direction in which its nose is pointing. These directions may be different if there is a crosswind or tidal current.
GPS compasses share the main advantages of gyrocompasses. They determine true North,  as opposed to magnetic North, and they are unaffected by perturbations of the Earth's magnetic field. Additionally, compared with gyrocompasses, they are much cheaper, they work better in polar regions, they are less prone to be affected by mechanical vibration, and they can be initialized far more quickly. However, they depend on the functioning of, and communication with, the GPS satellites, which might be disrupted by an electronic attack or by the effects of a severe solar storm. Gyrocompasses remain in use for military purposes (especially in submarines, where magnetic and GPS compasses are useless), but have been largely superseded by GPS compasses, with magnetic backups, in civilian contexts.
The first compasses in ancient Han dynasty China were made of lodestone, a naturally magnetized ore of iron.   Later compasses were made of iron needles, magnetized by striking them with a lodestone, which appeared in China by 1088 during the Song Dynasty, as described by Shen Kuo.  Dry compasses began to appear around 1300 in Medieval Europe and the Islamic world.   This was supplanted in the early 20th century by the liquid-filled magnetic compass. 
Modern compasses usually use a magnetized needle or dial inside a capsule completely filled with a liquid (lamp oil, mineral oil, white spirits, purified kerosene, or ethyl alcohol are common). While older designs commonly incorporated a flexible rubber diaphragm or airspace inside the capsule to allow for volume changes caused by temperature or altitude, some modern liquid compasses use smaller housings and/or flexible capsule materials to accomplish the same result.  The liquid inside the capsule serves to damp the movement of the needle, reducing oscillation time and increasing stability. Key points on the compass, including the north end of the needle are often marked with phosphorescent, photoluminescent, or self-luminous materials  to enable the compass to be read at night or in poor light. As the compass fill liquid is noncompressible under pressure, many ordinary liquid-filled compasses will operate accurately underwater to considerable depths.
Many modern compasses incorporate a baseplate and protractor tool, and are referred to variously as " orienteering", "baseplate", "map compass" or "protractor" designs. This type of compass uses a separate magnetized needle inside a rotating capsule, an orienting "box" or gate for aligning the needle with magnetic north, a transparent base containing map orienting lines, and a bezel (outer dial) marked in degrees or other units of angular measurement.  The capsule is mounted in a transparent baseplate containing a direction-of-travel (DOT) indicator for use in taking bearings directly from a map. 
Other features found on modern orienteering compasses are map and romer scales for measuring distances and plotting positions on maps, luminous markings on the face or bezels, various sighting mechanisms (mirror, prism, etc.) for taking bearings of distant objects with greater precision, gimbal-mounted, "global" needles for use in differing hemispheres, special rare-earth magnets to stabilize compass needles, adjustable declination for obtaining instant true bearings without resorting to arithmetic, and devices such as inclinometers for measuring gradients.  The sport of orienteering has also resulted in the development of models with extremely fast-settling and stable needles utilizing rare-earth magnets for optimal use with a topographic map, a land navigation technique known as terrain association.  Many marine compasses designed for use on boats with constantly shifting angles use dampening fluids such as isopar M or isopar L to limit the rapid fluctuation and direction of the needle. 
The military forces of a few nations, notably the United States Army, continue to issue field compasses with magnetized compass dials or cards instead of needles. A magnetic card compass is usually equipped with an optical, lensatic, or prismatic sight, which allows the user to read the bearing or azimuth off the compass card while simultaneously aligning the compass with the objective (see photo). Magnetic card compass designs normally require a separate protractor tool in order to take bearings directly from a map.  
The U.S. M-1950 military lensatic compass does not use a liquid-filled capsule as a damping mechanism, but rather electromagnetic induction to control oscillation of its magnetized card. A "deep-well" design is used to allow the compass to be used globally with a card tilt of up to 8 degrees without impairing accuracy.  As induction forces provide less damping than fluid-filled designs, a needle lock is fitted to the compass to reduce wear, operated by the folding action of the rear sight/lens holder. The use of air-filled induction compasses has declined over the years, as they may become inoperative or inaccurate in freezing temperatures or extremely humid environments due to condensation or water ingress. 
Some military compasses, like the U.S. M-1950 (
Cammenga 3H) military lensatic compass, the
Silva 4b Militaire, and the
Suunto M-5N(T) contain the radioactive material
) and a combination of phosphors.  The U.S. M-1950 equipped with self-luminous lighting contains 120 mCi (millicuries) of tritium. The purpose of the tritium and phosphors is to provide illumination for the compass, via radioluminescent tritium illumination, which does not require the compass to be "recharged" by sunlight or artificial light.  However, tritium has a half-life of only about 12 years,  so a compass that contains 120 mCi of tritium when new will contain only 60 when it is 12 years old, 30 when it is 24 years old, and so on. Consequently, the illumination of the display will fade.
Mariners' compasses can have two or more magnets permanently attached to a compass card, which moves freely on a pivot. A lubber line, which can be a marking on the compass bowl or a small fixed needle, indicates the ship's heading on the compass card. Traditionally the card is divided into thirty-two points (known as rhumbs), although modern compasses are marked in degrees rather than cardinal points. The glass-covered box (or bowl) contains a suspended gimbal within a binnacle. This preserves the horizontal position.
A thumb compass is a type of compass commonly used in orienteering, a sport in which map reading and terrain association are paramount. Consequently, most thumb compasses have minimal or no degree markings at all, and are normally used only to orient the map to magnetic north. An oversized rectangular needle or north indicator aids visibility. Thumb compasses are also often transparent so that an orienteer can hold a map in the hand with the compass and see the map through the compass. The best models use rare-earth magnets to reduce needle settling time to 1 second or less.
Small compasses found in clocks, mobile phones, and other electronic devices are solid-state microelectromechanical systems (MEMS) compasses, usually built out of two or three magnetic field sensors that provide data for a microprocessor. Often, the device is a discrete component which outputs either a digital or analog signal proportional to its orientation. This signal is interpreted by a controller or microprocessor and either used internally, or sent to a display unit. The sensor uses highly calibrated internal electronics to measure the response of the device to the Earth's magnetic field.
Apart from navigational compasses, other specialty compasses have also been designed to accommodate specific uses. These include:
The magnetic compass is very reliable at moderate latitudes, but in geographic regions near the Earth's magnetic poles it becomes unusable. As the compass is moved closer to one of the magnetic poles, the magnetic declination, the difference between the direction to geographical north and magnetic north, becomes greater and greater. At some point close to the magnetic pole the compass will not indicate any particular direction but will begin to drift. Also, the needle starts to point up or down when getting closer to the poles, because of the so-called magnetic inclination. Cheap compasses with bad bearings may get stuck because of this and therefore indicate a wrong direction.
Magnetic compasses are influenced by any fields other than Earth's. Local environments may contain magnetic mineral deposits and artificial sources such as MRIs, large iron or steel bodies, electrical engines or strong permanent magnets. Any electrically conductive body produces its own magnetic field when it is carrying an electric current. Magnetic compasses are prone to errors in the neighborhood of such bodies. Some compasses include magnets which can be adjusted to compensate for external magnetic fields, making the compass more reliable and accurate.
A compass is also subject to errors when the compass is accelerated or decelerated in an airplane or automobile. Depending on which of the Earth's hemispheres the compass is located and if the force is acceleration or deceleration the compass will increase or decrease the indicated heading. Compasses that include compensating magnets are especially prone to these errors, since accelerations tilt the needle, bringing it closer or further from the magnets.
Another error of the mechanical compass is the turning error. When one turns from a heading of east or west the compass will lag behind the turn or lead ahead of the turn. Magnetometers, and substitutes such as gyrocompasses, are more stable in such situations.
A magnetic rod is required when constructing a compass. This can be created by aligning an iron or steel rod with Earth's magnetic field and then tempering or striking it. However, this method produces only a weak magnet so other methods are preferred. For example, a magnetised rod can be created by repeatedly rubbing an iron rod with a magnetic lodestone. This magnetised rod (or magnetic needle) is then placed on a low friction surface to allow it to freely pivot to align itself with the magnetic field. It is then labeled so the user can distinguish the north-pointing from the south-pointing end; in modern convention the north end is typically marked in some way.
If a needle is rubbed on a lodestone or other magnet, the needle becomes magnetized. When it is inserted in a cork or piece of wood, and placed in a bowl of water it becomes a compass. Such devices were universally used as compass until the invention of the box-like compass with a 'dry' pivoting needle sometime around 1300.
Originally, many compasses were marked only as to the direction of magnetic north, or to the four cardinal points (north, south, east, west). Later, these were divided, in China into 24, and in Europe into 32 equally spaced points around the compass card. For a table of the thirty-two points, see compass points.
In the modern era, the 360-degree system took hold. This system is still in use today for civilian navigators. The degree system spaces 360 equidistant points located clockwise around the compass dial. In the 19th century some European nations adopted the " grad" (also called grade or gon) system instead, where a right angle is 100 grads to give a circle of 400 grads. Dividing grads into tenths to give a circle of 4000 decigrades has also been used in armies.
Most military forces have adopted the French " millieme" system. This is an approximation of a milli-radian (6283 per circle), in which the compass dial is spaced into 6400 units or "mils" for additional precision when measuring angles, laying artillery, etc. The value to the military is that one angular mil subtends approximately one metre at a distance of one kilometer. Imperial Russia used a system derived by dividing the circumference of a circle into chords of the same length as the radius. Each of these was divided into 100 spaces, giving a circle of 600. The Soviet Union divided these into tenths to give a circle of 6000 units, usually translated as "mils". This system was adopted by the former Warsaw Pact countries (e.g. Soviet Union, East Germany), often counterclockwise (see picture of wrist compass). This is still in use in Russia.
Because the Earth's magnetic field's inclination and intensity vary at different latitudes, compasses are often balanced during manufacture so that the dial or needle will be level, eliminating needle drag which can give inaccurate readings. Most manufacturers balance their compass needles for one of five zones, ranging from zone 1, covering most of the Northern Hemisphere, to zone 5 covering Australia and the southern oceans. This individual zone balancing prevents excessive dipping of one end of the needle which can cause the compass card to stick and give false readings. 
Some compasses feature a special needle balancing system that will accurately indicate magnetic north regardless of the particular magnetic zone. Other magnetic compasses have a small sliding counterweight installed on the needle itself. This sliding counterweight, called a 'rider', can be used for counterbalancing the needle against the dip caused by inclination if the compass is taken to a zone with a higher or lower dip. 
Like any magnetic device, compasses are affected by nearby ferrous materials, as well as by strong local electromagnetic forces. Compasses used for wilderness land navigation should not be used in proximity to ferrous metal objects or electromagnetic fields (car electrical systems, automobile engines, steel pitons, etc.) as that can affect their accuracy.  Compasses are particularly difficult to use accurately in or near trucks, cars or other mechanized vehicles even when corrected for deviation by the use of built-in magnets or other devices. Large amounts of ferrous metal combined with the on-and-off electrical fields caused by the vehicle's ignition and charging systems generally result in significant compass errors.
At sea, a ship's compass must also be corrected for errors, called deviation, caused by iron and steel in its structure and equipment. The ship is swung, that is rotated about a fixed point while its heading is noted by alignment with fixed points on the shore. A compass deviation card is prepared so that the navigator can convert between compass and magnetic headings. The compass can be corrected in three ways. First the lubber line can be adjusted so that it is aligned with the direction in which the ship travels, then the effects of permanent magnets can be corrected for by small magnets fitted within the case of the compass. The effect of ferromagnetic materials in the compass's environment can be corrected by two iron balls mounted on either side of the compass binnacle in concert with permanent magnets and a Flinders bar.  The coefficient represents the error in the lubber line, while the ferromagnetic effects and the non-ferromagnetic component. 
A similar process is used to calibrate the compass in light general aviation aircraft, with the compass deviation card often mounted permanently just above or below the magnetic compass on the instrument panel. Fluxgate electronic compasses can be calibrated automatically, and can also be programmed with the correct local compass variation so as to indicate the true heading.
A magnetic compass points to magnetic north pole, which is approximately 1,000 miles from the true geographic North Pole. A magnetic compass's user can determine true North by finding the magnetic north and then correcting for variation and deviation. Variation is defined as the angle between the direction of true (geographic) north and the direction of the meridian between the magnetic poles. Variation values for most of the oceans had been calculated and published by 1914.  Deviation refers to the response of the compass to local magnetic fields caused by the presence of iron and electric currents; one can partly compensate for these by careful location of the compass and the placement of compensating magnets under the compass itself. Mariners have long known that these measures do not completely cancel deviation; hence, they performed an additional step by measuring the compass bearing of a landmark with a known magnetic bearing. They then pointed their ship to the next compass point and measured again, graphing their results. In this way, correction tables could be created, which would be consulted when compasses were used when traveling in those locations.
Mariners are concerned about very accurate measurements; however, casual users need not be concerned with differences between magnetic and true North. Except in areas of extreme magnetic declination variance (20 degrees or more), this is enough to protect from walking in a substantially different direction than expected over short distances, provided the terrain is fairly flat and visibility is not impaired. By carefully recording distances (time or paces) and magnetic bearings traveled, one can plot a course and return to one's starting point using the compass alone. 
Compass navigation in conjunction with a map (terrain association) requires a different method. To take a map bearing or true bearing (a bearing taken in reference to true, not magnetic north) to a destination with a protractor compass, the edge of the compass is placed on the map so that it connects the current location with the desired destination (some sources recommend physically drawing a line). The orienting lines in the base of the compass dial are then rotated to align with actual or true north by aligning them with a marked line of longitude (or the vertical margin of the map), ignoring the compass needle entirely.  The resulting true bearing or map bearing may then be read at the degree indicator or direction-of-travel (DOT) line, which may be followed as an azimuth (course) to the destination. If a magnetic north bearing or compass bearing is desired, the compass must be adjusted by the amount of magnetic declination before using the bearing so that both map and compass are in agreement.  In the given example, the large mountain in the second photo was selected as the target destination on the map. Some compasses allow the scale to be adjusted to compensate for the local magnetic declination; if adjusted correctly, the compass will give the true bearing instead of the magnetic bearing.
The modern hand-held protractor compass always has an additional direction-of-travel (DOT) arrow or indicator inscribed on the baseplate. To check one's progress along a course or azimuth, or to ensure that the object in view is indeed the destination, a new compass reading may be taken to the target if visible (here, the large mountain). After pointing the DOT arrow on the baseplate at the target, the compass is oriented so that the needle is superimposed over the orienting arrow in the capsule. The resulting bearing indicated is the magnetic bearing to the target. Again, if one is using "true" or map bearings, and the compass does not have preset, pre-adjusted declination, one must additionally add or subtract magnetic declination to convert the magnetic bearing into a true bearing. The exact value of the magnetic declination is place-dependent and varies over time, though declination is frequently given on the map itself or obtainable on-line from various sites. If the hiker has been following the correct path, the compass' corrected (true) indicated bearing should closely correspond to the true bearing previously obtained from the map.
A compass should be laid down on a level surface so that the needle only rests or hangs on the bearing fused to the compass casing – if used at a tilt, the needle might touch the casing on the compass and not move freely, hence not pointing to the magnetic north accurately, giving a faulty reading. To see if the needle is well leveled, look closely at the needle, and tilt it slightly to see if the needle is swaying side to side freely and the needle is not contacting the casing of the compass. If the needle tilts to one direction, tilt the compass slightly and gently to the opposing direction until the compass needle is horizontal, lengthwise. Items to avoid around compasses are magnets of any kind and any electronics. Magnetic fields from electronics can easily disrupt the needle, preventing it from aligning with the Earth's magnetic fields, causing inaccurate readings. The Earth's natural magnetic forces are considerably weak, measuring at 0.5 gauss and magnetic fields from household electronics can easily exceed it, overpowering the compass needle. Exposure to strong magnets, or magnetic interference can sometimes cause the magnetic poles of the compass needle to differ or even reverse. Avoid iron rich deposits when using a compass, for example, certain rocks which contain magnetic minerals, like Magnetite. This is often indicated by a rock with a surface which is dark and has a metallic luster, not all magnetic mineral bearing rocks have this indication. To see if a rock or an area is causing interference on a compass, get out of the area, and see if the needle on the compass moves. If it does, it means that the area or rock the compass was previously at is causing interference and should be avoided.
Early in the Han Dynasty, between 300–200 BC, the Chinese fashioned a rudimentary compass out of lodestone ... the compass may have been used in the search for gems and the selection of sites for houses ... their directive power led to the use of compasses for navigation