The rock cycle describes how the three main rock types - sedimentary, igneous, and metamorphic - are interrelated and change into one another over geological time through processes like plate tectonics, weathering, and erosion. Sedimentary rocks form from the compaction or precipitation of minerals from weathered igneous and metamorphic rocks. Igneous rocks form when magma cools and crystallizes. Metamorphic rocks form when existing rocks are subjected to heat and pressure, often over long periods of time.