Takes a pairwise function and returns a function that can calculate the energy from a set of 3D positions.