What formulas are used in the drift mode?

Hello everyone.
I want to implement my coordinated turn mode, but in acro. My experience editing ardupilot is limited. Therefore, I initially want to explore the drift mode. As I understand it, there is a formula used to calculate yaw based on pitch and roll, in addition, the linear velocity obtained by gps, while the linear velocity is limited to 5000 (cm/s, but I’m not sure). But I wanted to find out in more detail: how these formulas were derived, and how the mode works in general. Can anyone help?

Check in ardupilot/ArduCopter/mode_drift.cpp at master · ArduPilot/ardupilot · GitHub
I think the formulas are fairly obvious in there.