refactor trig calcs into polygons.js