How does Terrain Compensation work in an Agriculture Guidance System?

Does anybody know the math behind terrain compensation? All I know is that to make these calculations, sensors such as accelerometers and gyroscopes, are mounted in different axes to compensate for roll, pitch, and yaw. What equations/formulas are used to convert the data from the sensors and figure out the correct position?

Example of Position Error

https://docs.novatel.com/OEM7/Content/R … _Roll1.png

An accelerometer can be used to measure tilt and roll angles with respect to vertical.

Use trigonometry to compute position errors from the angles. For the above example, 350*tan(10 degrees) = 61.7