Lidar/sonar and trigonometry

Hello! I hade not been able to find an answer to this, so if I missed something I apologize .

If I use a Lidar or sonar will APM:Copter use the pitch/yaw/roll angles to calculate distance to ground, or does the system assume that the rangefinder is always perpendicular to ground?