Take rotation formula from Wikipedia.