forked from: Rotation math

