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

Link copied to clipboard
constructor(vertices: MutableList<Euclidean2DPosition>, origin: Euclidean2DPosition, width: Double, height: Double, awtObstacles: List<Shape>)

Properties

Link copied to clipboard
open override val centroid: Euclidean2DPosition
Link copied to clipboard
open override val diameter: Double
Link copied to clipboard

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.

Link copied to clipboard
open val radius: Double

Functions

Link copied to clipboard
open override fun addVertex(index: Int, x: Double, y: Double): Boolean

Adds a vertex to the polygon.

Link copied to clipboard
open override fun advanceEdge(index: Int, step: Double): Boolean

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.

Link copied to clipboard
override fun asAwtShape(): Shape
Link copied to clipboard

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.

Link copied to clipboard
open override fun contains(shape: Shape): Boolean

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.

open override fun contains(vector: Euclidean2DPosition): Boolean

Delegated to AwtEuclidean2DShape (adopts the definition of insideness used by java.awt.Shapes).

Link copied to clipboard

Checks if a vector (= a point) is contained in the polygon, boundary excluded.

Link copied to clipboard

Checks if a vector (= a point) is contained in the polygon or lies on its boundary.

Link copied to clipboard
open override fun edges(): List<Segment2D<Euclidean2DPosition>>
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun extend(step: Double): Boolean

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.

Link copied to clipboard
open override fun getEdge(index: Int): Segment2DImpl<Euclidean2DPosition>
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun intersects(segment: Segment2D<Euclidean2DPosition>): Boolean

Checks if a segment intersects with the polygon, segments lying on the polygon's boundary are not considered to be intersecting.

open override fun intersects(other: Euclidean2DShape): Boolean

Delegated to AwtEuclidean2DShape unless other is AwtShapeCompatible, in which case intersects is used so as to guarantee maximum accuracy.

open override fun intersects(shape: Shape): Boolean

Delegated to java.awt.geom.Area, this is accurate and does not consider adjacent shapes to be intersecting.

Link copied to clipboard
open override fun isAdjacentTo(other: ConvexPolygon): Boolean

A polygon is adjacent to another if any of its points lies on the boundary of the other.

Link copied to clipboard
open override fun liesOnBoundary(vector: Euclidean2DPosition): Boolean

Checks if a vector (= a point) lies on the polygon's boundary.

Link copied to clipboard
open override fun moveVertex(index: Int, newX: Double, newY: Double): Boolean

Moves a vertex of the polygon to a new absolute position.

Link copied to clipboard
open override fun removeVertex(index: Int): Boolean

Removes a vertex from the polygon.

Link copied to clipboard
open override fun replaceEdge(index: Int, newEdge: Segment2D<Euclidean2DPosition>): Boolean

Replaces an edge of the polygon.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
Link copied to clipboard
open override fun vertices(): List<Euclidean2DPosition>