Polar coordinates rotation

bassik's icon

Hello everyone,

I am developing a M4L object that could control an immersive sound patch in Max from ableton.
I am using the HOA library for anyone familiar with this.

What I am struggling to find is a way to rotate polar coordinates.
I try to explain better.
HOA source position radar has a polar coordinate output for angle of rotation on the XY plane that is in [0, 2pi()] but the live.dial goes between -1, +1 hence I would need the output from the source position radar to be [-pi(), +pi()] and rotated by 180 deg.

I am struggling to do it.
IN Matlab I can do it by using the mod function (remainder after division) but mainly to do the opposite -pi() + pi() to 0 2PI()).

Anyone could possibly help?

Patch below

Max Patch
Copy patch and select New From Clipboard in Max.