improved rotation in topotools.py