One of the ways geologists can identify different rock types and tell how they were formed is by looking at slices of rock under the microscope.
These slices are ground so thinly (0.03mm) that light can pass through the minerals making up the rock.
An array of different colours and shades is seen as light is filtered through each mineral. Why? This happens because each type of mineral has a different atomic structure which only allows light through in particular orientations and at a certain speed.
An expert geologist can identify all the minerals in a rock by looking at how their colours change when the slice is rotated, and when artificial filters are added.
Also, the arrangement and size of the minerals tells us which formed first and how quickly their crystals grew.
All this information adds up to give us a name for the rock type and a detailed story of how it was formed.