better math, fixes touchhandling and angle functions

Change-Id: I9bc6f653bda00069d3db3cc272473f173980e5e0