public class GeoPolygon extends GeoArea
Modifier | Constructor and Description |
---|---|
protected |
GeoPolygon()
Creates a new instance of GeoPolygogn, but does not assign any values
|
|
GeoPolygon(List<double[]> points)
Creates a new instance of GeoPolygon
|
Modifier and Type | Method and Description |
---|---|
List<double[]> |
boundingBox()
Returns an ArrayList of 4 points that define an oriented rectangle enclosing the GeoPolygon
|
double |
boundingCircleRadius()
Returns the radius of a circle (centered at the area centroid) that encloses the area
|
double[] |
closestPoint(double[] point)
Returns the vertex of the polygon that is closest to the parameter point
NOTE: This method provides the closest VERTEX, not the closest arbitrary point on the polygon
|
boolean |
contains(double[] point)
Returns true if the point defined by the parameter is inside the GeoPolygon
|
AreaElementType |
convertToAreaElementType()
Converts the GeoCircle to an AVCL area object
|
List<double[]> |
getAdjacentVertices(int index)
Returns an array list with the locations of the vertices adjacent to a specified vertex
Will return null if the specified index is less than zero or greater than the total vertices
|
double |
getArea()
Returns the area (square meters) of the GeoPolygon
|
double[] |
getCentroid()
Returns a double[2] with the (x, y) position of the area's centroid
|
double[] |
getIntersection(double[] point1,
double[] point2)
Determines the closest point of intersection between the region and a line (defined with 2 points)
If the line is tangent to the polygon, null will be returned (no intersection)
|
double[] |
getSegmentIntersection(double[] point1,
double[] point2)
Determines the closest point of intersection between the region and a line segment
If the line is tangent to the polygon, null will be returned (no intersection)
|
double[] |
getSegmentIntersection2(double[] point1,
double[] point2)
Determines the closest point of intersection between the region and a line segment
If the line is tangent to the polygon, null will be returned (no intersection)
If the startpoint of the segment is in the area and the segment proceeds further into
the area, then the start will not be returned as the intersection, but the next
intersection will (effectively, if point1 is in the area, the nearest intersection
where the segment leaves the area will be returned)
|
ArrayList<double[]> |
getTangents(double[] start)
Determines the points on the area's edge that are
tangentially reachable from a specified point
|
double[] |
getVertex(int index)
Returns a double[] with the (x, y) coordinate of the vertex specified by the index
|
boolean |
isConcave()
Returns true if the polygon is concave.
|
boolean |
isOnEdge(double[] point)
Returns true if the point defined by the parameter is on the edge of the GeoArea
|
static void |
main(String[] args) |
int |
numIntersections(double[] point1,
double[] point2)
Computes how many times a line passing through two points intersects a polygon edge
|
int |
numVertices()
Returns the number of vertices in the polygon
|
int |
onVertex(double[] point)
Returns the index of a vertex that a point parameter is on (-1 if not on a vertex)
|
List<double[]> |
orientedBoundingBox()
Returns the corner points of an oriented bounding box for the region
Will default to the orthogonal bounding box, so must be over-ridden for
GeoArea types that are not necessarily orthogonally oriented (polygon)
(this method does nothing more than reasssert the original GeoArea method)
|
void |
resetOrientedBoundingBox()
Recomputes the polygon's oriented bounded box when vertices are added or removed
|
protected void |
setVertices(List<double[]> points)
Assigns a new set of points to the GeoPolygon
|
String |
toMATLABString(String colorCode)
Generates a string representation of the Path object that can be used to plot the path in MATLAB
|
String |
toString()
Generates a string representation of the GeoPolygon object
|
distance, distance, dotProduct, getLineIntersection, getLineSegmentIntersection, getLineToSegmentIntersection, isColocated, isColocated, isInLineSegment, isInSegment, isOnSegment, isOnSegment
protected GeoPolygon()
public GeoPolygon(List<double[]> points)
points
- ordered list of polygon vertices.
Each list element is a double[2] (x, y) coordinateprotected void setVertices(List<double[]> points)
points
- ordered list of polygon vertices.
Each list element is a double[2] (x, y) coordinatepublic int onVertex(double[] point)
point
- public int numVertices()
public double[] getVertex(int index)
index
- public ArrayList<double[]> getTangents(double[] start)
getTangents
in class GeoArea
start
- the point from which tangents are to be determined start[0] = x, start[1] = ypublic List<double[]> getAdjacentVertices(int index)
index
- index to the vertex of interestpublic int numIntersections(double[] point1, double[] point2)
point1
- first point on the line (point1[0] = x, point1[1] = y)point2
- second point on the line (point2[0] = x, point2[1] = y)public double[] getIntersection(double[] point1, double[] point2)
getIntersection
in class GeoArea
point1
- first point on the line (point1[0] = x, point1[1] = y)point2
- second point on the line (point2[0] = x, point2[1] = y)public double[] getSegmentIntersection(double[] point1, double[] point2)
getSegmentIntersection
in class GeoArea
point1
- first point on the line (point1[0] = x, point1[1] = y)point2
- second point on the line (point2[0] = x, point2[1] = y)public double[] getSegmentIntersection2(double[] point1, double[] point2)
point1
- first point on the line (point1[0] = x, point1[1] = y)point2
- second point on the line (point2[0] = x, point2[1] = y)public double getArea()
public double[] getCentroid()
getCentroid
in class GeoArea
public double[] closestPoint(double[] point)
closestPoint
in class GeoArea
point
- double[2] with the (x, y) coordinates of the point being testedpublic List<double[]> boundingBox()
boundingBox
in class GeoArea
public void resetOrientedBoundingBox()
public List<double[]> orientedBoundingBox()
orientedBoundingBox
in class GeoArea
public double boundingCircleRadius()
boundingCircleRadius
in class GeoArea
public boolean contains(double[] point)
public boolean isOnEdge(double[] point)
public boolean isConcave()
public String toString()
public AreaElementType convertToAreaElementType()
convertToAreaElementType
in class GeoArea
public static void main(String[] args)
args
- public String toMATLABString(String colorCode)
toMATLABString
in class GeoArea
colorCode
- MATLAB code for the color that is to be used in plotting the areas