Fix prism code when below

The problem was actually in the atan2 function:
* sometimes returns positive values for negative angles and vice-versa
* sometimes returns 2*pi for zero angle

The fix was to wrap atan2 and fix the result to fall where I want it to.

TODO:

- [ ] Fix problem with the `log` of zero values.