The Lang algorithm defines a search region based on the tolerance and the look-ahead value. The tolerance is the perpendicular distance from each point on the original line to a line that joins the first and last points of the segment. The look-ahead value is the number of points to be considered.

In this example, the look-ahead value is 4.
This means that the line segment in the first step starts at point A and ends at point E. A straight line is drawn between those points, then each point in between is evaluated.

In this example, points B, C, and D all fall within the tolerance and are therefore deleted.

A new line segment starts at point E and continues for four points. In this case, the straight line is drawn between E and I.
Two points fall outside of the tolerance, therefore the search area is reduced by one point. The new line is drawn between E and H.

Points F and G now fall within the tolerance and are removed.
A search area is now drawn between H and J.

Point I falls inside the tolerance and is removed.
The simplified line looks like this:
