Techniques for detecting boundary crossings may involve the use of
rectangles that approximate a boundary. Data defining the rectangles may
be retrieved, and a current location of a monitored device may be
identified. The current location may be compared with the rectangles, and
a determination that the current location is located within a rectangle
may indicate a boundary crossing. To simplify the calculations on the
monitored device, certain calculations may be performed in advance. For
example, an angle between a selected side of a particular rectangle and
an axis of the coordinate system may be determined, and the particular
rectangle may be rotated by the angle to orient the rotated rectangle
parallel to the axis of the coordinate system. Subsequently, location
coordinates for a monitored device may be rotated and compared with a
corresponding rotated rectangle to determine whether the monitored device
is located within the particular rectangle.