For example I'm intending to read XZ or YZ to see the pitch angle for the control of an inverted pendulum ... I personally thought it's a low cost way of doing it compared to an encoder
Surely what you need is an accelerometer, you know that the period is always the same, it just moves faster when first set in motion (I'm not totally sure that's correct, my knowledge of basic physics is pretty ragged). If that's correct, there will be a relationship between angle and acceleration. With calibration you should end up with a look up table of acceleration/angle. Of course you'll only need to generate the table once.

Also I cant imagine how you would orient the magnetometer to even hint at the angle.

BTW anyway, you couldn't use an encoder if you want the pendulum to be "true", pivot must be frictionless.

Sounds like an interesting project, have fun.

George