A technique for the calculation of mass, energy, and momentum densities at planes in molecular dynamics simulations