added function for calculating the object orientation