public class RegularPolygon extends Shape
Constructor and Description |
---|
RegularPolygon(float centerX,
float centerY,
float radius,
int totalSides,
float rotationSymmetry)
Constructor
|
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(Shape shape)
|
boolean |
contains(com.badlogic.gdx.math.Vector2 vector2)
Returns if a
Vector2 is contained inside this Shape |
Shape |
copy()
Returns an exact copy of this
Shape |
void |
draw(Graphics g)
Draws this shape using a
Graphics instance |
EdgeIterator |
edgeIterator()
Returns an
EdgeIterator for looping over the edges of this
Shape |
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 the distance from this
Shape to a set of coordinates |
float |
getMaxX()
Returns the right-most x coordinate
|
float |
getMaxY()
Returns the bottom-most y coordinate
|
float |
getMinX()
Returns the left-most x coordinate
|
float |
getMinY()
Returns the top-most y coordinate
|
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 |
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
|
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(Shape shape)
|
boolean |
intersectsLineSegment(float x1,
float y1,
float x2,
float y2)
Returns if this
Shape intersects a line segment |
boolean |
intersectsLineSegment(com.badlogic.gdx.math.Vector2 pointA,
com.badlogic.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 |
set(float centerX,
float centerY)
Sets the center X and Y coordinates.
|
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 |
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, getDistanceTo, subtract
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 draw(Graphics g)
Shape
Graphics
instancepublic void fill(Graphics g)
Shape
Graphics
instancepublic boolean intersects(Polygon polygon)
RegularPolygon
intersects a Polygon
polygon
- The Polygon
to checkRegularPolygon
and Polygon
intersectpublic boolean intersects(Rectangle rectangle)
Rectangle
intersects this
RegularPolygon
rectangle
- The Rectangle
to checkRegularPolygon
and Rectangle
intersectpublic boolean contains(float x, float y)
Shape
Shape
public boolean contains(com.badlogic.gdx.math.Vector2 vector2)
Shape
Vector2
is contained inside this Shape
public boolean intersects(Shape shape)
Shape
intersects
in class Shape
shape
- The Shape
to checkShape
intersects the specified Shape
public boolean intersects(LineSegment lineSegment)
Shape
Shape
intersects the specified
LineSegment
intersects
in class Shape
lineSegment
- The LineSegment
to checkShape
intersects the LineSegment
public boolean intersectsLineSegment(com.badlogic.gdx.math.Vector2 pointA, com.badlogic.gdx.math.Vector2 pointB)
Shape
Shape
intersects a line segmentintersectsLineSegment
in class Shape
pointA
- The first point in the line segmentpointB
- The second point in the line segmentShape
intersects the line segmentpublic boolean intersectsLineSegment(float x1, float y1, float x2, float y2)
Shape
Shape
intersects a line segmentintersectsLineSegment
in class Shape
x1
- 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 pointShape
intersects the line segmentpublic float getDistanceTo(float x, float y)
Shape
Shape
to a set of coordinatesgetDistanceTo
in class Shape
x
- The x coordinatey
- The y coordinatepublic float getRotation()
Shape
Shape
getRotation
in class Shape
public void setRotation(float degrees)
Shape
Shape
with its first point as the
originsetRotation
in class Shape
degrees
- The rotation in degreespublic void setRotationAround(float centerX, float centerY, float degrees)
Shape
Shape
with a specified point as the
originsetRotationAround
in class Shape
centerX
- The origin/center x coordinatecenterY
- The origin/center y coordinatedegrees
- The rotation in degreespublic void rotate(float degrees)
Shape
Shape
by a specified amount of degrees with its
first point as the originpublic void rotateAround(float centerX, float centerY, float degrees)
Shape
Shape
by a specified amount of degrees around a
specified pointrotateAround
in class Shape
centerX
- The origin/center x coordinatecenterY
- The origin/center y coordinatedegrees
- The rotation in degreespublic float getX()
RegularPolygon
public void setX(float centerX)
RegularPolygon
public float getY()
RegularPolygon
public void setY(float centerY)
RegularPolygon
public void set(float centerX, float centerY)
setX(float)
and setY(float)
separately.public void translate(float translateX, float translateY)
Shape
public float getRadius()
RegularPolygon
public void setRadius(float radius)
RegularPolygon
Note: This operation is expensivepublic void scale(float scale)
Shape
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()
Shape
getNumberOfSides
in class Shape
public EdgeIterator edgeIterator()
Shape
EdgeIterator
for looping over the edges of this
Shape
edgeIterator
in class Shape
EdgeIterator
public boolean isCircle()
Shape
public Polygon getPolygon()
Shape
getPolygon
in class Shape
Shape
is a Circle
public float getMinX()
Shape
public float getMinY()
Shape
public float getMaxX()
Shape
public float getMaxY()
Shape
public float getCenterX()
Shape
Circle
this is the same as x.getCenterX
in class Shape
public float getCenterY()
Shape
Circle
this is the same as y.getCenterY
in class Shape