A binary algebra describing crystal structures with closely packed anions. II. A common system of reference for cubic and hexagonal structures