Did you profile this?  `acos` kills many GPUs, probably mobile in particular.  Despite the `if` statement, this code is likely to execute all the time.  This is probably too high a price to pay in the case that we're not using a rotation.

In general, can we move some of this work to the CPU and do it once?