Consider the problem of determining whether a point is inside relatively simple polygons such as triangles or quadrilaterals. The treatment of the case of generic polygons is more complex and is left to the reader (and optionally reduced to the triangle/quadrilateral case).
In the case of triangles and quadrilaterals, the approaches presented are very efficient when it is necessary to perform comparisons between a single polygon and a large number of points, as such techniques allow the use of precalculations: the fundamental idea is to exploit a transformation of the polygon's coordinate space into a space where comparisons are easier to perform.
For example, a parallelogram formed by two generating vectors can always be transformed into a unit square through an affine transformation
. A point
lies inside the parallelogram if
and
. The same transformation applies to triangles formed by the same generating vectors, but with the comparison
and
. To determine if a point lies inside the parallelogram, only 4 multiplications and 6 additions are necessary. The cost of creating the affine transformation is higher, but if the number of comparisons is large, this constant overhead becomes negligible.
To transform generic quadrilaterals into a unit square , one must instead use the homographic transformation (see section 1.10). Despite the high initial cost of creating the transformation, the check for whether a point belongs to the geometric figure is relatively simple
| (1.86) |
Paolo medici