APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.math

public Class Ellipse

extends Object
implements Serializable, Shape2D
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.math.Shape2D, java.io.Serializable
Imports
java.io.Serializable, com.badlogic.gdx.utils.NumberUtils

A convenient 2D ellipse class, based on the circle class
Author
tonyp7

Field Summary

Modifier and TypeField and Description
public float
private static final long
public float
public float
x

public float
y

Constructor Summary

AccessConstructor and Description
public
Ellipse()

Construct a new ellipse with all values set to zero

public
Ellipse(Ellipse
Ellipse to construct a copy of.
ellipse
)

Copy constructor

public
Ellipse(float
X coordinate of the center of the ellipse
x
,
float
Y coordinate of the center of the ellipse
y
,
float
the width of the ellipse
width
,
float
the height of the ellipse
height
)

Constructs a new ellipse

public
Ellipse(Vector2
Position vector of the center of the ellipse
position
,
float
the width of the ellipse
width
,
float
the height of the ellipse
height
)

Constructs a new ellipse

public
Ellipse(Vector2
Position vector of the center of the ellipse
position
,
Vector2
Size vector
size
)

Constructs a new ellipse

public
Ellipse(Circle
The circle to take the values of
circle
)

Constructs a new Ellipse from the position and radius of a Circle (since circles are special cases of ellipses).

Method Summary

Modifier and TypeMethod and Description
public float
area()

Returns: The area of this Ellipse as MathUtils#PI * Ellipse#width * Ellipse#height

public float

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
circumference
()

Approximates the circumference of this Ellipse.

public boolean

Returns:

true if this ellipse contains the given point; false otherwise.
contains
(float
X coordinate
x
,
float
Y coordinate
y
)

Implements com.badlogic.gdx.math.Shape2D.contains.

Checks whether or not this ellipse contains the given point.

public boolean

Returns:

true if this ellipse contains the given point; false otherwise.
contains
(Vector2
Position vector
point
)

Implements com.badlogic.gdx.math.Shape2D.contains.

Checks whether or not this ellipse contains the given point.

public boolean
equals(Object o)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public void
set(float
X coordinate of the center of the ellipse
x
,
float
Y coordinate of the center of the ellipse
y
,
float
the width of the ellipse
width
,
float
the height of the ellipse
height
)

Sets a new position and size for this ellipse.

public void
set(Ellipse
The ellipse to copy the position and size of.
ellipse
)

Sets a new position and size for this ellipse based upon another ellipse.

public void
set(Circle circle)

public void
set(Vector2 position, Vector2 size)

public Ellipse

Returns:

this ellipse for chaining
setPosition
(Vector2
The position vector of the center of the ellipse
position
)

Sets the x and y-coordinates of ellipse center from a Vector2.

public Ellipse

Returns:

this ellipse for chaining
setPosition
(float
The x-coordinate of the center of the ellipse
x
,
float
The y-coordinate of the center of the ellipse
y
)

Sets the x and y-coordinates of ellipse center

public Ellipse

Returns:

this ellipse for chaining
setSize
(float
The width
width
,
float
The height
height
)

Sets the width and height of this ellipse

public String
toString()

Overrides java.lang.Object.toString.

Returns a String representation of this Ellipse of the form [x,y,width,height].

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

heightback to summary
public float height
serialVersionUIDback to summary
private static final long serialVersionUID
widthback to summary
public float width
xback to summary
public float x
yback to summary
public float y

Constructor Detail

Ellipseback to summary
public Ellipse()

Construct a new ellipse with all values set to zero

Ellipseback to summary
public Ellipse(Ellipse ellipse)

Copy constructor

Parameters
ellipse:Ellipse

Ellipse to construct a copy of.

Ellipseback to summary
public Ellipse(float x, float y, float width, float height)

Constructs a new ellipse

Parameters
x:float

X coordinate of the center of the ellipse

y:float

Y coordinate of the center of the ellipse

width:float

the width of the ellipse

height:float

the height of the ellipse

Ellipseback to summary
public Ellipse(Vector2 position, float width, float height)

Constructs a new ellipse

Parameters
position:Vector2

Position vector of the center of the ellipse

width:float

the width of the ellipse

height:float

the height of the ellipse

Ellipseback to summary
public Ellipse(Vector2 position, Vector2 size)

Constructs a new ellipse

Parameters
position:Vector2

Position vector of the center of the ellipse

size:Vector2

Size vector

Ellipseback to summary
public Ellipse(Circle circle)

Constructs a new Ellipse from the position and radius of a Circle (since circles are special cases of ellipses).

Parameters
circle:Circle

The circle to take the values of

Method Detail

areaback to summary
public float area()
Returns:float

The area of this Ellipse as MathUtils#PI * Ellipse#width * Ellipse#height

circumferenceback to summary
public float circumference()

Approximates the circumference of this Ellipse. Oddly enough, the circumference of an ellipse is actually difficult to compute exactly.

Returns:float

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

containsback to summary
public boolean contains(float x, float y)

Implements com.badlogic.gdx.math.Shape2D.contains.

Checks whether or not this ellipse contains the given point.

Parameters
x:float

X coordinate

y:float

Y coordinate

Returns:boolean

true if this ellipse contains the given point; false otherwise.

containsback to summary
public boolean contains(Vector2 point)

Implements com.badlogic.gdx.math.Shape2D.contains.

Checks whether or not this ellipse contains the given point.

Parameters
point:Vector2

Position vector

Returns:boolean

true if this ellipse contains the given point; false otherwise.

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
setback to summary
public void set(float x, float y, float width, float height)

Sets a new position and size for this ellipse.

Parameters
x:float

X coordinate of the center of the ellipse

y:float

Y coordinate of the center of the ellipse

width:float

the width of the ellipse

height:float

the height of the ellipse

setback to summary
public void set(Ellipse ellipse)

Sets a new position and size for this ellipse based upon another ellipse.

Parameters
ellipse:Ellipse

The ellipse to copy the position and size of.

setback to summary
public void set(Circle circle)
setback to summary
public void set(Vector2 position, Vector2 size)
setPositionback to summary
public Ellipse setPosition(Vector2 position)

Sets the x and y-coordinates of ellipse center from a Vector2.

Parameters
position:Vector2

The position vector of the center of the ellipse

Returns:Ellipse

this ellipse for chaining

setPositionback to summary
public Ellipse setPosition(float x, float y)

Sets the x and y-coordinates of ellipse center

Parameters
x:float

The x-coordinate of the center of the ellipse

y:float

The y-coordinate of the center of the ellipse

Returns:Ellipse

this ellipse for chaining

setSizeback to summary
public Ellipse setSize(float width, float height)

Sets the width and height of this ellipse

Parameters
width:float

The width

height:float

The height

Returns:Ellipse

this ellipse for chaining

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a String representation of this Ellipse of the form [x,y,width,height].

Annotations
@Override