atan2 implementation