|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.umd.cfar.lamp.viper.geometry.PolyList edu.umd.cfar.lamp.viper.geometry.ConvexPolygon
A class representing a Convex Polygon. Polygon with vertexes listed in counterclockwise order such that all interior angles are less than 180 degrees. Unlike polylist or BoundingBox, this is limited to containing a single polygon.
Field Summary |
Fields inherited from class edu.umd.cfar.lamp.viper.geometry.PolyList |
area, bbox, CARVE_POLYS, composed, originals, polys |
Constructor Summary | |
ConvexPolygon()
Creates an empty convex polygon, whatever that means. |
|
ConvexPolygon(ConvexPolygon old)
Copy constructor. |
|
ConvexPolygon(CountingStringTokenizer input)
Creates a new convex polygon from the given set of tokens. |
|
ConvexPolygon(int[] points)
Initialize a convex polygon from a sequence of points. |
|
ConvexPolygon(java.util.List points)
Initialize a convex polygon from a sequence of points. |
Method Summary | |
static ConvexPolygon[] |
add(ConvexPolygon P,
ConvexPolygon Q)
Returns a set of polygons that, together, cover all and only the region covered by the specified polygons. |
boolean |
addVertex(Pnt point)
Adds a single point to the polygon. |
Rational |
area()
Finds the area inside the polygon. |
protected void |
clearPolygon()
|
static ConvexPolygon[] |
clip(ConvexPolygon P,
Pnt a,
Pnt b)
Cuts the polygon into two slices. |
java.lang.Object |
clone()
Gets a copy of this polygon. |
boolean |
contains(int X,
int Y)
Tests to see if the point is within this region. |
boolean |
contains(Pnt point)
Tests to see if the point is within this region. |
boolean |
equals(java.lang.Object o)
Tests to see if this region is the same as that covered by the specified shape. |
Pnt |
getCentroid()
Gets the center of the bounding box of the polygon, for now. |
PolyList |
getIntersection(PolyList other)
Gets the region shared between this polygon and all those in the specified PolyList. |
Pnt |
getNearIntersection(Pnt q1)
Get the point of intersection between the ray from the centroid of this box through q1 that is closest to q1. |
java.util.Iterator |
getPolys()
Gets all the component polygons of this set. |
protected void |
initBbox()
Creates a BoundingBox around this, for use by getBoundingBox, etc. |
static ConvexPolygon |
intersection(ConvexPolygon P,
ConvexPolygon Q)
This creates a new area that is the intersection of both. |
boolean |
isInside(ConvexPolygon P)
Tests to see if the specified polygon is completely contained within this polygon. |
static PolyList |
subtract(ConvexPolygon P,
ConvexPolygon Q)
Subtracts the second shape from the first. |
java.lang.String |
toString()
Gets a string representation of the polygon. |
java.lang.String |
toStringListOfPoints()
Gets a String representation of the polygon as a list of points, where each point is given as (x,y). |
Methods inherited from class edu.umd.cfar.lamp.viper.geometry.PolyList |
addPoly, clearPolyList, getBoundingBox, getConvexPolygonArray, getFragmentationCount, getOriginals, getPoints, hashCode, intersection, intersects, union |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ConvexPolygon()
public ConvexPolygon(CountingStringTokenizer input) throws BadDataException
input
- the tokenized string to parse
BadDataException
- if the string isn't formatted properlypublic ConvexPolygon(ConvexPolygon old)
old
- the convex polygon to duplicate.public ConvexPolygon(int[] points)
points
- a list of points as (x, y) pairs, such that point k's
cooridinates are (points[k/2], points[k/2 + 1]).public ConvexPolygon(java.util.List points)
points
- a list of viper.geometry.Pnt objectsMethod Detail |
protected void initBbox()
PolyList
initBbox
in class PolyList
public java.lang.Object clone()
clone
in class PolyList
this
public PolyList getIntersection(PolyList other)
getIntersection
in class PolyList
other
- the region to intersect with
public Pnt getNearIntersection(Pnt q1)
q1
- A point that is not the centroid.
public Pnt getCentroid()
getCentroid
in interface HasCentroid
public static ConvexPolygon[] clip(ConvexPolygon P, Pnt a, Pnt b)
P
- the polygon to slicea
- a point along the slicing lineb
- another point, != to a, along the slicing line
public static PolyList subtract(ConvexPolygon P, ConvexPolygon Q)
P
- the shape to subtract fromQ
- the shape to subtract
public static ConvexPolygon[] add(ConvexPolygon P, ConvexPolygon Q)
P
- a convex polygon to unionQ
- a convex polygon to union
public boolean isInside(ConvexPolygon P)
P
- the polygon to check for
true
iff all of P is within this polygonpublic static ConvexPolygon intersection(ConvexPolygon P, ConvexPolygon Q)
P
- a polygon to intersectQ
- a polygon to intersect
public boolean addVertex(Pnt point) throws BadDataException
addVertex
in class PolyList
point
- the point to add to the polygon
BadDataException
- if attempting to add reflex vertexprotected void clearPolygon()
public final java.lang.String toStringListOfPoints()
toStringListOfPoints
in class PolyList
public java.lang.String toString()
toString
in class PolyList
public Rational area()
area
in class PolyList
public boolean contains(int X, int Y)
X
- the x-coordinate of the point to checkY
- the y-coordinate of the point to check
true
iff the point is within the polygonpublic boolean contains(Pnt point)
contains
in class PolyList
point
- the point to look for within the polygon
true
iff the point is within the polygonpublic boolean equals(java.lang.Object o)
equals
in class PolyList
o
- the shape to check against. Works for most children of PolyList
false
if the two regions are unequalpublic java.util.Iterator getPolys()
getPolys
in class PolyList
this
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |