ExtendableConvexPolygonInEnvironment
An ExtendableConvexPolygon located inside an environment with obstacles. Obstacles, as well as the environment's boundaries, are taken into account when the polygon is extended (i.e. the polygon is prevented from intersecting an obstacle or growing beyond such boundaries). A rectangular region is assumed, its origin, width and height are to be specified. Both java.awt.Shapes and ConvexPolygons can be specified as obstacles (see awtObstacles and polygonalObstacles). This class is explicitly designed for the algorithm contained in NaviGator.generateNavigationGraph. TODO(improve the quality of this class)
Constructors
Properties
Obstacles represented as ConvexPolygons, are assumed to be mutable but limited to the extension (i.e. they can only grow, not shrink). This is the behavior of seeds used by NaviGator.generateNavigationGraph, making this assumption allows to cache useful data such as whether an edge can still advance or an obstacle has already been encountered. This is a var but is assumed to be set only once before starting to extend this polygon.
Functions
Advances an edge in its normal direction of a quantity equal to step, if extend has modified the growth direction of the edge so as to follow an oblique obstacle (advanced case), the modified growth direction is used. The polygon is prevented from growing out of the environment's boundaries, but not from intersecting obstacles.
Finds the edge of the polygon closest to the provided segment, i.e. the first one that would collide (= intersect) with the segment in case the polygon extended on each side.
Checks if the polygon contains a polygonal java.awt.Shape (i.e. without curved segments). A polygonal shape is contained in a polygon if all of its points are contained in (or lie on the boundary of) the latter.
Delegated to AwtEuclidean2DShape (adopts the definition of insideness used by java.awt.Shapes).
Checks if a vector (= a point) is contained in the polygon, boundary excluded.
Checks if a vector (= a point) is contained in the polygon or lies on its boundary.
Extends the polygon in each direction of a quantity equal to step. The advancement of an edge is blocked if an obstacle is intersected, unless in a particular case called advanced case. Such case shows up when a single vertex of the polygon intruded an obstacle, but no vertex from the obstacle intruded the polygon. Plus, the intruded side of the obstacle should be oblique (or better, its slope should be different from the one of the advancing edge). When this happens, we can do a simple operation in order to keep growing and allow a higher coverage of the walkable area. We increment the order of the polygon (by adding a vertex) and adjust the direction of growth in order for the new edge to follow the side of the obstacle.
Checks if a segment intersects with the polygon, segments lying on the polygon's boundary are not considered to be intersecting.
Delegated to AwtEuclidean2DShape unless other is AwtShapeCompatible, in which case intersects is used so as to guarantee maximum accuracy.
Delegated to java.awt.geom.Area, this is accurate and does not consider adjacent shapes to be intersecting.
A polygon is adjacent to another if any of its points lies on the boundary of the other.
Checks if a vector (= a point) lies on the polygon's boundary.
Moves a vertex of the polygon to a new absolute position.
Removes a vertex from the polygon.
Replaces an edge of the polygon.