The determination of the layer number in nanoscale thin layered crystals is a challenging problem of technological relevance. In addition to innovative experimental techniques, a thorough knowledge of the underlying lattice dynamics is required. Starting from phenomenological atomic interaction potentials we have carried out an analytical study of the low-frequency optical phonon dispersions in layered crystals. At the gamma point of the two-dimensional Brillouin zone the optical phonon frequencies correspond to rigid-plane shearing and compression modes. We have investigated graphene multilayers (GML) and hexagonal boron-nitride multilayers (BNML). The frequencies show a characteristic dependence on . The results which are represented in the form of fan diagrams are very similar for both materials. Due to charge neutrality within layers Coulomb forces play no role, only van der Waals forces between nearest neighbor layers are relevant. The theoretical results agree with recent low-frequency Raman results on rigid-layer modes [Tan et al., Nature Mater. 11, 294 (2012)] in GML and double-resonant Raman scattering data on rigid-layer compression modes [Herziger et al., Phys. Rev. B 85, 235447 (2012)] in GML.