use Math::Trig instead of re-implementing math locally; sort use while here