Selfmade Tilt compensated Compass Pitch, Roll, Yaw

Thanks !

@Viki

How can i get the values for f and q ?