public class Polygon extends Shape
geometry, positionChangeListeners, sizeChangeListeners| Constructor and Description |
|---|
Polygon(float[] vertices)
Constructor.
|
Polygon(Geometry geometry,
float[] vertices)
|
Polygon(org.mini2Dx.gdx.math.Vector2[] points)
Constructor with vectors.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPoint(float x,
float y)
Adds an additional point to this
Polygon |
void |
addPoint(org.mini2Dx.gdx.math.Vector2 point)
Adds an additional point to this
Polygon |
boolean |
contains(float x,
float y)
Returns if a set of coordinates are contained inside this shape
|
boolean |
contains(Polygon polygon) |
boolean |
contains(Sizeable shape)
Returns if this shape contains the specified shape
|
boolean |
contains(org.mini2Dx.gdx.math.Vector2 vector2)
Returns if a
Vector2 is contained inside this shape |
Shape |
copy()
Returns an exact copy of this
Shape |
void |
dispose()
|
void |
draw(Graphics g)
Draws this shape using a
Graphics instance |
EdgeIterator |
edgeIterator()
Returns an
EdgeIterator for looping over the edges of this
Shape |
boolean |
equals(java.lang.Object obj) |
void |
fill(Graphics g)
Fills this shape using a
Graphics instance |
float |
getCenterX()
Returns the center x coordinate of this object.
|
float |
getCenterY()
Returns the center y coordinate of this object.
|
float |
getDistanceTo(float x,
float y)
Returns this distance between this object's x,y coordinates and the
provided xy coordinates
|
float |
getHeight()
Returns the height of this object
|
float |
getMaxX()
Returns max X coordinate of this
Polygon |
float |
getMaxY()
Returns max Y coordinate of this
Polygon |
float |
getMinX()
Returns min X coordinate of this
Polygon |
float |
getMinY()
Returns min Y coordinate of this
Polygon |
int |
getNumberOfSides()
Returns the number of edges of this object
|
Polygon |
getPolygon()
|
float |
getRotation()
Returns the rotation of this
Shape |
org.mini2Dx.gdx.utils.ShortArray |
getTriangles()
Returns an array of vertex indices that the define the triangles which
make up this
Polygon |
float[] |
getVertices() |
float |
getWidth()
Returns the width of this object
|
float |
getX()
Returns the x coordinate
|
float |
getX(int index)
Returns the x coordinate of the corner at the specified index
|
float |
getY()
Returns the y coordinate
|
float |
getY(int index)
Returns the y coordinate of the corner at the specified index
|
int |
hashCode() |
boolean |
intersects(Circle circle) |
boolean |
intersects(LineSegment lineSegment)
Returns if this
Shape intersects the specified
LineSegment |
boolean |
intersects(Polygon polygon)
Returns if this
Polygon intersects another |
boolean |
intersects(Rectangle rectangle)
|
boolean |
intersects(Sizeable shape)
Returns if this shape intersects a shape
|
boolean |
intersects(Triangle triangle)
|
boolean |
intersectsLineSegment(float x1,
float y1,
float x2,
float y2)
Returns if this shape intersects a line segment
|
boolean |
intersectsLineSegment(org.mini2Dx.gdx.math.Vector2 pointA,
org.mini2Dx.gdx.math.Vector2 pointB)
Returns if this shape intersects a line segment
|
boolean |
isCircle()
|
boolean |
isEquilateral() |
boolean |
isEquilateral(float tolerance) |
boolean |
isRectangle() |
boolean |
isSameAs(Polygon polygon)
Returns if this
Polygon is the same as another |
Polygon |
lerp(Polygon target,
float alpha) |
void |
removePoint(float x,
float y)
Removes a point from this
Polygon |
void |
removePoint(org.mini2Dx.gdx.math.Vector2 point)
Removes a point from this
Polygon |
void |
rotate(float degrees)
Rotates this
Shape by a specified amount of degrees with its
first point as the origin |
void |
rotateAround(float centerX,
float centerY,
float degrees)
Rotates this
Shape by a specified amount of degrees around a
specified point |
void |
scale(float scale)
Scales the radius of this shape.
|
void |
set(Polygon polygon) |
void |
setCenter(float x,
float y)
Sets the center x,y coordinate of this object
|
void |
setCenterX(float x)
Sets the center x coordinate
|
void |
setCenterY(float y)
Sets the center y coordianate
|
void |
setRadius(float radius)
Sets the radius of this shape.
|
void |
setRotation(float degrees)
Sets the rotation of this
Shape with its first point as the
origin |
void |
setRotationAround(float centerX,
float centerY,
float degrees)
Sets the rotation of this
Shape with a specified point as the
origin |
void |
setVertices(float[] vertices) |
void |
setVertices(org.mini2Dx.gdx.math.Vector2[] vertices) |
void |
setX(float x)
Sets the x coordinate of this object
|
void |
setXY(float x,
float y)
Sets the x and y coordinate of this object
|
void |
setY(float y)
Sets the y coordinate of this object
|
protected float |
sign(float x,
float y,
float p1x,
float p1y,
float p2x,
float p2y) |
java.lang.String |
toString() |
void |
translate(float translateX,
float translateY)
Translates the x and y coordinate of this object
|
protected boolean |
triangleContains(float x,
float y,
float p1x,
float p1y,
float p2x,
float p2y,
float p3x,
float p3y) |
add, addPostionChangeListener, addSizeChangeListener, clearPositionChangeListeners, clearPositionListeners, clearPositionListeners, clearSizeChangeListeners, clearSizeListeners, clearSizeListeners, getDistanceTo, moveTowards, moveTowards, notifyPositionChangeListeners, notifyPositionListeners, notifyPositionListeners, notifySizeChangeListeners, notifySizeListeners, notifySizeListeners, removePositionChangeListener, removePositionListener, removePositionListener, removeSizeChangeListener, removeSizeListener, removeSizeListener, setRotationAround, subtractpublic Polygon(Geometry geometry, float[] vertices)
geometry - The Geometry poolvertices - The verticespublic Polygon(float[] vertices)
vertices - All points in x,y pairs. E.g. x1,y1,x2,y2,etc.public Polygon(org.mini2Dx.gdx.math.Vector2[] points)
points - All points in the polygonpublic void dispose()
Shapepublic boolean isSameAs(Polygon polygon)
Polygon is the same as anotherpolygon - The Polygon to compare toprotected boolean triangleContains(float x,
float y,
float p1x,
float p1y,
float p2x,
float p2y,
float p3x,
float p3y)
protected float sign(float x,
float y,
float p1x,
float p1y,
float p2x,
float p2y)
public boolean contains(float x,
float y)
Sizeablex - The x coordinate to checky - The y coordinate to checkpublic boolean contains(org.mini2Dx.gdx.math.Vector2 vector2)
SizeableVector2 is contained inside this shapevector2 - The Vector2 to checkVector2public boolean contains(Sizeable shape)
Sizeablepublic boolean contains(Polygon polygon)
public boolean intersects(Sizeable shape)
Sizeablepublic boolean intersects(Triangle triangle)
public boolean intersects(Rectangle rectangle)
public boolean intersects(Circle circle)
public boolean intersects(LineSegment lineSegment)
ShapeShape intersects the specified
LineSegmentintersects in interface Sizeableintersects in class ShapelineSegment - The LineSegment to checkShape intersects the LineSegmentpublic boolean intersectsLineSegment(org.mini2Dx.gdx.math.Vector2 pointA,
org.mini2Dx.gdx.math.Vector2 pointB)
SizeablepointA - The first point in the line segmentpointB - The second point in the line segmentpublic boolean intersectsLineSegment(float x1,
float y1,
float x2,
float y2)
Sizeablex1 - The x coordinate of the first pointy1 - The y coordinate of the first pointx2 - The x coordinate of the second pointy2 - The y coordinate of the second pointpublic float getWidth()
Sizeablepublic float getHeight()
Sizeablepublic float getDistanceTo(float x,
float y)
Positionablex - The x coordinate to measure distance toy - The y coordinate to measure distance topublic void addPoint(float x,
float y)
Polygonx - The x coordinatey - The y coordinatepublic void addPoint(org.mini2Dx.gdx.math.Vector2 point)
Polygonpoint - The point to add as a Vector2public void removePoint(float x,
float y)
Polygonx - The x coordinatey - The y coordinatepublic void removePoint(org.mini2Dx.gdx.math.Vector2 point)
Polygonpoint - The point to remove as a Vector2public int getNumberOfSides()
ShapegetNumberOfSides in interface SizeablegetNumberOfSides in class Shapepublic void draw(Graphics g)
ShapeGraphics instancepublic void fill(Graphics g)
ShapeGraphics instancepublic float[] getVertices()
public void setVertices(float[] vertices)
public void setVertices(org.mini2Dx.gdx.math.Vector2[] vertices)
public float getRotation()
ShapeShapegetRotation in class Shapepublic void setRotation(float degrees)
ShapeShape with its first point as the
originsetRotation in class Shapedegrees - The rotation in degreespublic void rotate(float degrees)
ShapeShape by a specified amount of degrees with its
first point as the originpublic void setRotationAround(float centerX,
float centerY,
float degrees)
ShapeShape with a specified point as the
originsetRotationAround in class ShapecenterX - The origin/center x coordinatecenterY - The origin/center y coordinatedegrees - The rotation in degreespublic void rotateAround(float centerX,
float centerY,
float degrees)
ShapeShape by a specified amount of degrees around a
specified pointrotateAround in class ShapecenterX - The origin/center x coordinatecenterY - The origin/center y coordinatedegrees - The rotation in degreespublic float getX()
Polygonpublic float getY()
Polygonpublic float getX(int index)
index - The point indexpublic float getY(int index)
index - The point indexpublic float getCenterX()
SizeableCircle
this is the same as x.public float getCenterY()
SizeableCircle
this is the same as y.public void setCenter(float x,
float y)
Sizeablex - The x coordinate of the shape's centery - The y coordinate of the shape's centerpublic void setCenterX(float x)
Sizeablex - The x coordinate of the shape's centerpublic void setCenterY(float y)
Sizeabley - The y coordinate of the shape's centerpublic float getMinX()
Polygonpublic float getMinY()
Polygonpublic float getMaxX()
Polygonpublic float getMaxY()
Polygonpublic org.mini2Dx.gdx.utils.ShortArray getTriangles()
Polygonpublic void setX(float x)
Positionablex - The x coordinatepublic void setY(float y)
Positionabley - The y coordinatepublic void setXY(float x,
float y)
Positionablex - The x coordinatey - The y coordinatepublic void setRadius(float radius)
SizeablePolygon shapes, this will
stretch in/out the shape from its center. Note that Polygons must
be equilateral.radius - The radius in pixelspublic void scale(float scale)
SizeablePolygon shapes, this will
stretch in/out the shape from its center. Note that Polygons must
be equilateral.scale - The amount to scale by (e.g. 2.0 = double the size)public void set(Polygon polygon)
public void translate(float translateX,
float translateY)
Shapepublic EdgeIterator edgeIterator()
ShapeEdgeIterator for looping over the edges of this
ShapeedgeIterator in class ShapeEdgeIteratorpublic boolean isEquilateral()
public boolean isEquilateral(float tolerance)
public boolean isRectangle()
public boolean isCircle()
Shapepublic Polygon getPolygon()
ShapegetPolygon in interface SizeablegetPolygon in class ShapeShape is a Circlepublic java.lang.String toString()
toString in class java.lang.Object