Refactoring ray rotation