|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.phys2d.raw.shapes.AbstractShape net.phys2d.raw.shapes.Polygon
A polygon represented by a list of its vertices in counterclockwise ordering. Note that the term 'counterclockwise' depends on the orientation of the axes: if x points to the right and y points up, the vertices are counter clockwise. This means that on many displays the ordering of vertices will be clockwise because the y axis is pointing down. TODO: the polygon is immutable but that could be changed
Field Summary | |
protected float |
area
The total area of this polygon |
protected Vector2f |
centroid
The center of mass of this polygon |
protected Vector2f[] |
vertices
The vertices of this polygon in counterclockwise order |
Fields inherited from class net.phys2d.raw.shapes.AbstractShape |
bounds |
Constructor Summary | |
protected |
Polygon()
A constructor that allows for overloading without using the public constructor. |
|
Polygon(ROVector2f[] vertices)
Construct the polygon with a list of vertices sorted in counterclockwise order. |
Method Summary | |
protected float |
computeArea()
Computes the area as described by Paul Borke. |
protected float |
computeBoundingCircleRadius()
Computes the radius of an approximation of a minimal bounding circle which has its origin at (0,0) and sets this.bounds. |
protected Vector2f |
computeCentroid()
Compute the centroid (center of mass) as described by Paul Borke. |
boolean |
contains(ROVector2f p)
Test whether or not the point p is in this polygon in O(n), where n is the number of vertices in this polygon. |
float |
getArea()
Get the area of this polygon |
Vector2f |
getCentroid()
Get the center of mass (aka centroid) for this polygon. |
Vector2f |
getCentroid(ROVector2f displacement,
float rotation)
Returns a translated and rotated copy of this poly's centroid. |
ROVector2f |
getNearestPoint(ROVector2f p)
Get point on this polygon's hull that is closest to p. |
float |
getSurfaceFactor()
Some factor based on the edges length of the shape |
ROVector2f[] |
getVertices()
Returns a copy of the list of vertices. |
Vector2f[] |
getVertices(ROVector2f displacement,
float rotation)
Returns a translated and rotated copy of this poly's vertices. |
boolean |
isConvex()
Check wether or not the polygon is convex. |
Methods inherited from class net.phys2d.raw.shapes.AbstractShape |
getBounds |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.phys2d.raw.shapes.Shape |
getBounds |
Field Detail |
protected Vector2f[] vertices
protected float area
protected Vector2f centroid
Constructor Detail |
public Polygon(ROVector2f[] vertices)
vertices
- Vertices sorted in counterclockwise orderprotected Polygon()
Method Detail |
protected float computeArea()
protected Vector2f computeCentroid()
protected float computeBoundingCircleRadius()
public float getArea()
public Vector2f getCentroid()
public ROVector2f[] getVertices()
public boolean isConvex()
public Vector2f[] getVertices(ROVector2f displacement, float rotation)
displacement
- The displacement with wich all therotation
-
public Vector2f getCentroid(ROVector2f displacement, float rotation)
displacement
- The displacement with wich all therotation
-
public boolean contains(ROVector2f p)
p
- The point to be tested for inclusion in this polygon
public ROVector2f getNearestPoint(ROVector2f p)
p
- The point to search the closest point for
public float getSurfaceFactor()
Shape
getSurfaceFactor
in interface Shape
Shape.getSurfaceFactor()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |