Changed implementation of the rotate method to use vector algebra