I suspect you'll be spending a lot of time in `polar`, which is a rather expensive function. If you're going to do any optimization, I'd start by creating a lookup table for it.