public class RegularPolygon extends Shape
geometry, positionChangeListeners, sizeChangeListeners| Modifier | Constructor and Description |
|---|---|
|
RegularPolygon(float centerX,
float centerY,
float radius,
int totalSides,
float rotationSymmetry)
Constructor
|
protected |
RegularPolygon(Geometry geometry,
int totalSides,
float rotationSymmetry) |
|
RegularPolygon(RegularPolygon regularPolygon)
Constructs a new
RegularPolygon as a copy of another |
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(float x,
float y)
Returns if a set of coordinates are contained inside this shape
|
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 object
|
float |
getMaxY()
Returns max Y coordinate of this object
|
float |
getMinX()
Returns min X coordinate of this object
|
float |
getMinY()
Returns min Y coordinate of this object
|
int |
getNumberOfSides()
Returns the number of edges of this object
|
Polygon |
getPolygon()
|
float |
getRadius()
Returns the radius of this
RegularPolygon |
float |
getRotation()
Returns the rotation of this
Shape |
float |
getWidth()
Returns the width of this object
|
float |
getX()
Returns the center X coordinate of this
RegularPolygon |
float |
getX(int index)
Returns the x coordinate of the corner at the specified index
|
float |
getY()
Returns the center Y coordinate of this
RegularPolygon |
float |
getY(int index)
Returns the y coordinate of the corner at the specified index
|
int |
hashCode() |
boolean |
intersects(LineSegment lineSegment)
Returns if this
Shape intersects the specified
LineSegment |
boolean |
intersects(Polygon polygon)
Returns if this
RegularPolygon intersects a Polygon |
boolean |
intersects(Rectangle rectangle)
Returns if the specified
Rectangle intersects this
RegularPolygon |
boolean |
intersects(Sizeable shape)
Returns if this shape intersects a shape
|
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()
|
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 |
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
RegularPolygon
Note: This operation is expensive |
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 |
setX(float centerX)
Sets the X coordinate of this
RegularPolygon |
void |
setXY(float centerX,
float centerY)
Sets the center X and Y coordinates.
|
void |
setY(float centerY)
Sets the Y coordinate of this
RegularPolygon |
void |
translate(float translateX,
float translateY)
Translates the x and y coordinate of this object
|
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, subtractprotected RegularPolygon(Geometry geometry, int totalSides, float rotationSymmetry)
public RegularPolygon(float centerX,
float centerY,
float radius,
int totalSides,
float rotationSymmetry)
centerX - The center X coordinatecenterY - The center Y coordinateradius - The distance from the center to the corner pointstotalSides - The total sides of this shaperotationSymmetry - The rotational symmetry of the corner points from the centerpublic RegularPolygon(RegularPolygon regularPolygon)
RegularPolygon as a copy of anotherregularPolygon - The RegularPolygon to copypublic void dispose()
Shapepublic void draw(Graphics g)
ShapeGraphics instancepublic void fill(Graphics g)
ShapeGraphics instancepublic boolean intersects(Polygon polygon)
RegularPolygon intersects a Polygonpolygon - The Polygon to checkRegularPolygon and Polygon intersectpublic boolean intersects(Rectangle rectangle)
Rectangle intersects this
RegularPolygonrectangle - The Rectangle to checkRegularPolygon and Rectangle intersectpublic 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 intersects(Sizeable shape)
Sizeablepublic 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 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 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 rotate(float degrees)
ShapeShape by a specified amount of degrees with its
first point as the originpublic 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()
RegularPolygonpublic void setX(float centerX)
RegularPolygoncenterX - The center X coordinatepublic float getY()
RegularPolygonpublic void setY(float centerY)
RegularPolygoncenterY - The center Y coordinatepublic void setXY(float centerX,
float centerY)
setX(float) and setY(float)
separately.centerX - The center X coordinatecenterY - The center Y coordinatepublic void translate(float translateX,
float translateY)
Shapepublic float getRadius()
RegularPolygonpublic void setRadius(float radius)
RegularPolygon
Note: This operation is expensiveradius - The distance between the center and its cornerspublic 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 float getX(int index)
index - The index where 0 = the top corner and increments in a
clockwise methodpublic float getY(int index)
index - The index where 0 = the top corner and increments in a
clockwise methodpublic int getNumberOfSides()
ShapegetNumberOfSides in interface SizeablegetNumberOfSides in class Shapepublic EdgeIterator edgeIterator()
ShapeEdgeIterator for looping over the edges of this
ShapeedgeIterator in class ShapeEdgeIteratorpublic boolean isCircle()
Shapepublic Polygon getPolygon()
ShapegetPolygon in interface SizeablegetPolygon in class ShapeShape is a Circlepublic float getMinX()
Sizeablepublic float getMinY()
Sizeablepublic float getMaxX()
Sizeablepublic float getMaxY()
Sizeablepublic 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 center