All objects in the map are described by the (x,y) vertex coordinates of polygons. The map OOP object creates a table of the edges of all polygons. In the simulation of the sensors, rays are tested for intersection with each edge in the polygon list.
Figure 12.1, shows a ray drawn out from a sensor intersecting with an edge of a polygon. The following equations are used to determine if intersection occurred.
(D) is the slope of the intersection. If the slope is zero then it is assumed that the edge is parallel to the ray. No test for ``parallel'' and ``dead on'' is made. This condition is assumed to be a miss.
If the tests make it this far, (S) will provide the intersection distance between the sensor and the particular edge of the polygon. All of the sensors are compared to all of the edges in the map in this manner. The closest intersections for each sensor are recorded. The next section provides a more detailed description of the sensors.
(t) is based on the parametric equation of the polygon edge. The edge only exists from 0 <= t <= 1. Therefore if (t) is not in the domain of [0,1], then the ray does not intersect that edge.
This module is part of a robotics simulation that was demonstrated in a Master's Thesis entitled: