Package com.badlogic.gdx.math
Class Ellipse
- java.lang.Object
-
- com.badlogic.gdx.math.Ellipse
-
- All Implemented Interfaces:
Shape2D,java.io.Serializable
public class Ellipse extends java.lang.Object implements java.io.Serializable, Shape2D
A convenient 2D ellipse class, based on the circle class- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Ellipse()Construct a new ellipse with all values set to zeroEllipse(float x, float y, float width, float height)Constructs a new ellipseEllipse(Circle circle)Ellipse(Ellipse ellipse)Copy constructorEllipse(Vector2 position, float width, float height)Constructs a new ellipseEllipse(Vector2 position, Vector2 size)Constructs a new ellipse
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatarea()floatcircumference()Approximates the circumference of thisEllipse.booleancontains(float x, float y)Checks whether or not this ellipse contains the given point.booleancontains(Vector2 point)Checks whether or not this ellipse contains the given point.booleanequals(java.lang.Object o)inthashCode()voidset(float x, float y, float width, float height)Sets a new position and size for this ellipse.voidset(Circle circle)voidset(Ellipse ellipse)Sets a new position and size for this ellipse based upon another ellipse.voidset(Vector2 position, Vector2 size)EllipsesetPosition(float x, float y)Sets the x and y-coordinates of ellipse centerEllipsesetPosition(Vector2 position)Sets the x and y-coordinates of ellipse center from aVector2.EllipsesetSize(float width, float height)Sets the width and height of this ellipse
-
-
-
Constructor Detail
-
Ellipse
public Ellipse()
Construct a new ellipse with all values set to zero
-
Ellipse
public Ellipse(Ellipse ellipse)
Copy constructor- Parameters:
ellipse- Ellipse to construct a copy of.
-
Ellipse
public Ellipse(float x, float y, float width, float height)Constructs a new ellipse- Parameters:
x- X coordinatey- Y coordinatewidth- the width of the ellipseheight- the height of the ellipse
-
Ellipse
public Ellipse(Vector2 position, float width, float height)
Constructs a new ellipse- Parameters:
position- Position vectorwidth- the width of the ellipseheight- the height of the ellipse
-
Ellipse
public Ellipse(Vector2 position, Vector2 size)
Constructs a new ellipse- Parameters:
position- Position vectorsize- Size vector
-
-
Method Detail
-
contains
public boolean contains(float x, float y)Checks whether or not this ellipse contains the given point.
-
contains
public boolean contains(Vector2 point)
Checks whether or not this ellipse contains the given point.
-
set
public void set(float x, float y, float width, float height)Sets a new position and size for this ellipse.- Parameters:
x- X coordinatey- Y coordinatewidth- the width of the ellipseheight- the height of the ellipse
-
set
public void set(Ellipse ellipse)
Sets a new position and size for this ellipse based upon another ellipse.- Parameters:
ellipse- The ellipse to copy the position and size of.
-
set
public void set(Circle circle)
-
setPosition
public Ellipse setPosition(Vector2 position)
Sets the x and y-coordinates of ellipse center from aVector2.- Parameters:
position- The position vector- Returns:
- this ellipse for chaining
-
setPosition
public Ellipse setPosition(float x, float y)
Sets the x and y-coordinates of ellipse center- Parameters:
x- The x-coordinatey- The y-coordinate- Returns:
- this ellipse for chaining
-
setSize
public Ellipse setSize(float width, float height)
Sets the width and height of this ellipse- Parameters:
width- The widthheight- The height- Returns:
- this ellipse for chaining
-
area
public float area()
- Returns:
- The area of this
EllipseasMathUtils.PI*width*height
-
circumference
public float circumference()
Approximates the circumference of thisEllipse. Oddly enough, the circumference of an ellipse is actually difficult to compute exactly.- Returns:
- The Ramanujan approximation to the circumference of an ellipse if one dimension is at least three times longer than the other, else the simpler approximation
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-