Lots of sines and cosines here. Might it be better to create a lookup table?