Bonding study of TiC and TiN. II. Theory.