Heading <> Course Over Ground.
Consider a person on a travelator or simply side-stepping. The direction you are facing only loosely correlates to the direction you are actually moving in.
This is most noticeable for relatively slow watercraft and aircraft with speed of similar magnitude to the current or windspeed, but is a significant consideration even for faster craft.
The options are some sort of compass sensor - magnetic or gyrocompass, or for orientation of *LARGE* objects, differential GPS between two widely separated antennae, typically mounted to the bow and stern of a medium or large ship. Its *POSSIBLE* to construct a north seeking solid state gyro system that in combination with a 3 axis accelerometer, detects the Earth's rotation, and thus its orientation with respect to the polar axis, thus eliminating gyro heading drift, but its extremely difficult to do in a compact form factor on a moving platform.