fix plotphi range
use trigonometric optimizations