explain the formation of three main rock types and there roles in the rock cycle