b̲o̲o̲l̲e̲a̲n̲ p̲r̲o̲c̲e̲d̲u̲r̲e̲ POINT IN POLYGON (n, x, y, x0, y0); v̲a̲l̲u̲e̲ n, x0, y0; i̲n̲t̲e̲g̲e̲r̲ n; a̲r̲r̲a̲y̲ x, y; r̲e̲a̲l̲ x0, y0; c̲o̲m̲m̲e̲n̲t̲ if the point (x[i], y[i]) (i = 1, 2, ..., n) are - in this cyclic order - the vertices of a simple closed polygon and (x0, y0) is a point not on any side of the polygon, then the procedure dtermines, by setting "point in polygon" to true, wheter (x0, y0) lies in the interior of the polygon; b̲e̲g̲i̲n̲ i̲n̲t̲e̲g̲e̲r̲ i; b̲o̲o̲l̲e̲a̲n̲ b; x[n + 1] := x[1]; y[n + 1] := y[1]; b := t̲r̲u̲e̲; f̲o̲r̲ i := 1 s̲t̲e̲p̲ 1 u̲n̲t̲i̲l̲ n d̲o̲ i̲f̲ (y0 < y[i] ≡ y0 > y[i+1]) ∧ x0 - x[i] - (y0 - y[i])×(x[i + 1] - x[i])/(y[i + 1] - y[i]) < 0 t̲h̲e̲n̲ b := ¬b; POINT IN POLYGON := ¬b e̲n̲d̲ POINT IN POLYGON;