|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.lmu.ifi.dbs.elki.data.spatial.Polygon
public class Polygon

Class representing a simple polygon. While you can obviously store non-simple polygons in this, note that many of the supplied methods will assume that the polygons are simple.
| Field Summary | |
|---|---|
private double[] |
max
Maximum values |
private double[] |
min
Minimum values |
private List<Vector> |
points
The actual points |
| Constructor Summary | |
|---|---|
Polygon(List<Vector> points)
Constructor. |
|
Polygon(List<Vector> points,
double minx,
double maxx,
double miny,
double maxy)
|
|
| Method Summary | |
|---|---|
void |
appendToBuffer(StringBuffer buf)
Append the polygon to the buffer. |
boolean |
containsPoint2D(Vector v)
Point in polygon test, based on http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by W. |
ListIterator<Vector> |
descendingIterator()
Return an iterator that iterates the list backwards. |
Vector |
get(int idx)
Get a vector by index. |
int |
getDimensionality()
Returns the dimensionality of the object. |
double |
getMax(int dimension)
Returns the maximum coordinate at the specified dimension. |
double |
getMin(int dimension)
Returns the minimum coordinate at the specified dimension. |
boolean |
intersects2DIncomplete(Polygon other)
Simple polygon intersection test. |
Iterator<Vector> |
iterator()
|
ListIterator<Vector> |
listIterator()
Get a list iterator. |
int |
size()
Get the polygon length. |
int |
testClockwise()
Test polygon orientation. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private List<Vector> points
private double[] min
private double[] max
| Constructor Detail |
|---|
public Polygon(List<Vector> points)
points - Polygon points
public Polygon(List<Vector> points,
double minx,
double maxx,
double miny,
double maxy)
| Method Detail |
|---|
public Iterator<Vector> iterator()
iterator in interface Iterable<Vector>public ListIterator<Vector> listIterator()
public ListIterator<Vector> descendingIterator()
public void appendToBuffer(StringBuffer buf)
buf - Buffer to append topublic String toString()
toString in class Objectpublic int size()
public Vector get(int idx)
idx - Index to get
public int getDimensionality()
SpatialComparable
getDimensionality in interface SpatialComparablepublic double getMin(int dimension)
SpatialComparable
getMin in interface SpatialComparabledimension - the dimension for which the coordinate should be returned,
where 1 ≤ dimension ≤ getDimensionality()
public double getMax(int dimension)
SpatialComparable
getMax in interface SpatialComparabledimension - the dimension for which the coordinate should be returned,
where 1 ≤ dimension ≤ getDimensionality()
public int testClockwise()
public boolean intersects2DIncomplete(Polygon other)
FIXME: while this is found on some web pages as "solution" and satisfies or needs, it clearly is not correct; not even for convex polygons: Consider a cross where the two bars are made out of four vertices each. No vertex is inside the other polygon, yet they intersect. I knew this before writing this code, but this O(n) code was the simplest thing to come up with, and it would work for our current data sets. A way to fix this is to augment it with the obvious O(n*n) segment intersection test. (Note that you will still need to test for point containment, since the whole polygon could be contained in the other!)
other - Other polygon
public boolean containsPoint2D(Vector v)
v - Point to test
|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||