A rotary encoder, also called a shaft encoder, is an electro-mechanical device that converts the angular position or motion of a shaft or axle to analog or digital output signals.
There are two main types of rotary encoder: absolute and incremental. The output of an absolute encoder indicates the current shaft position. The output of an incremental encoder provides information about the motion of the shaft, which typically is processed elsewhere into information such as position, speed and distance. (Adapted form Wikipedia)
For a related part, check out the potentiometer page, as potentiometers also communicate information about position of a shaft in rotation, but do so by varying resistance.