|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.awt.Polygon
|
+--auc.geom.Polygon2D
A class for the polygon representation with the real coordinates and basic polygon geometry functions.
| Field Summary | |
protected Vector2D |
max
The maximum coordinates of the minimal rectangle that covers the polygon. |
protected Vector2D |
min
The minimum coordinates of the minimal rectangle that covers the polygon. |
protected java.util.Vector |
vertices
The list of vertices. |
| Fields inherited from class java.awt.Polygon |
bounds, npoints, xpoints, ypoints |
| Constructor Summary | |
Polygon2D()
Constructs empty polygon instance. |
|
Polygon2D(int[] xpoints,
int[] ypoint,
int npoints)
Constructs a polygon from the list of coordinates. |
|
Polygon2D(Polygon2D poly)
Constructs a copy of the given polygon instance. |
|
| Method Summary | |
void |
addPoint(int x,
int y)
Adds a vertex to this polygon. |
boolean |
addVertex(Vector2D p)
Adds a new vertex to the polygon at the end of the vertices list. |
java.util.Vector |
concavities()
Calculates the concavities in this polygon. |
boolean |
contains(double x,
double y)
Evaluates whether the given point is inside this polygon. |
boolean |
contains(int x,
int y)
Evaluates whether the given point is inside this polygon. |
boolean |
contains(Polygon2D p)
Checks whether this polygon contains polygon p. |
boolean |
contains(Vector2D p)
The alternative way of checking the point containment. |
Polygon2D |
convex()
Calculates the minimal convex polygon which contains this polygon. |
boolean |
equals(java.lang.Object obj)
Calculates whether this polygon is equal to the given Polygon2D. |
int |
findVertex(double x,
double y)
Searches for the vertex in the list of polygon vertices. |
Vector2D |
getMax()
|
double |
getMaxX()
|
double |
getMaxY()
|
Vector2D |
getMin()
|
double |
getMinX()
|
double |
getMinY()
|
java.util.Iterator |
getVertexIterator()
Returns the vertex list iterator to access each vertex. |
int |
getVerticesCount()
Returns the number of vertices in this polygon. |
static Vector2D |
intersection(Vector2D l1p1,
Vector2D l1p2,
Vector2D l2p1,
Vector2D l2p2)
Finds the intersection point of two segments. |
boolean |
intersects(Vector2D p1,
Vector2D p2)
Tells whether the segment crosses the polygon. |
static void |
main(java.lang.String[] arg)
Test for Polygon2D#convex() and Polygon2D#concavities() functions. |
double |
orientation()
Calculates the orientation of this polygon. |
boolean |
removeVertex(double x,
double y)
Removes a vertex of given coordinates from polygon structure. |
boolean |
removeVertex(Vector2D v)
Alternative way to remove the vertex. |
java.lang.String |
toString()
The string representation is enumeration of vertices string representations. |
| Methods inherited from class java.awt.Polygon |
contains, contains, contains, contains, getBoundingBox, getBounds, getBounds2D, getPathIterator, getPathIterator, inside, intersects, intersects, translate |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.util.Vector vertices
Vector2Dprotected Vector2D min
getMin()protected Vector2D max
getMax()| Constructor Detail |
public Polygon2D()
public Polygon2D(Polygon2D poly)
poly - a reference to a given polygon.
public Polygon2D(int[] xpoints,
int[] ypoint,
int npoints)
xpoints - x-coordinate of the pointypoints - y-coordinate of the pointnpoints - number of oints to include into polygon.Polygon.Polygon(int[],int[],int)| Method Detail |
public int getVerticesCount()
public void addPoint(int x,
int y)
addPoint in class java.awt.Polygonx - the x-coordinate of the vertex.y - the y-coordinate of the vertex.Polygon.addPoint(int, int)public boolean addVertex(Vector2D p)
p - The vertex point to be added.public java.util.Iterator getVertexIterator()
public int findVertex(double x,
double y)
x - The x-axis coordinate of vertex.y - The y-axis coordinate of vertex.public boolean removeVertex(Vector2D v)
v - vector that points to one of the polygon vertices.removeVertex(double, double)
public boolean removeVertex(double x,
double y)
x - The x-axis coordinate of vertex.y - The y-axis coordinate of vertex.precision - The precision parameter to test the vector equality.removeVertex(Vector2D)
public static Vector2D intersection(Vector2D l1p1,
Vector2D l1p2,
Vector2D l2p1,
Vector2D l2p2)
s1p1 - the beginning point of the first segments1p2 - the ending point of the first segments2p1 - the beginning point of the second segments2p2 - the ending point of the second segment
public boolean intersects(Vector2D p1,
Vector2D p2)
p1 - the beginning point of the segmentp2 - the ending point of the segment
public boolean contains(double x,
double y)
contains in class java.awt.Polygonx - The x-axis coordinate of the point.y - The y-axis coordinate of the point.
public boolean contains(int x,
int y)
contains in class java.awt.Polygonx - the x-coordinate of the point.y - the y-coordinate of the point.contains(double, double)public double orientation()
public java.util.Vector concavities()
public Polygon2D convex()
public boolean contains(Vector2D p)
p - the vector which points to the desired point.contains(double, double)public boolean contains(Polygon2D p)
p - The polygon for checking.public double getMinX()
minpublic double getMaxX()
maxpublic double getMinY()
minpublic double getMaxY()
maxpublic Vector2D getMin()
minpublic Vector2D getMax()
maxpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the polygon object.public java.lang.String toString()
toString in class java.lang.Objectpublic static void main(java.lang.String[] arg)
arg - the list of arguments from command line (not used).
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||