toxi.geom
Class Polygon2D

java.lang.Object
  extended by toxi.geom.Polygon2D

public class Polygon2D
extends java.lang.Object

Wrapper


Field Summary
 java.util.List<Vec2D> vertices
           
 
Constructor Summary
Polygon2D()
           
Polygon2D(java.util.List<Vec2D> points)
           
 
Method Summary
 Polygon2D add(Vec2D p)
           
 float getArea()
          Computes the area of the polygon, provided it isn't self intersecting.
 Vec2D getCentroid()
          Computes the polygon's centre of mass.
 int getNumPoints()
          Returns the number of polygon vertices.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vertices

public java.util.List<Vec2D> vertices
Constructor Detail

Polygon2D

public Polygon2D()

Polygon2D

public Polygon2D(java.util.List<Vec2D> points)
Method Detail

add

public Polygon2D add(Vec2D p)

getArea

public float getArea()
Computes the area of the polygon, provided it isn't self intersecting. Code ported from: http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/

Returns:
polygon area

getCentroid

public Vec2D getCentroid()
Computes the polygon's centre of mass. Code ported from: http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/

Returns:
centroid point

getNumPoints

public int getNumPoints()
Returns the number of polygon vertices.

Returns:
vertex count