simplified formula by defining my own enums for orientations.