Package arc.math.geom
Class Ellipse
java.lang.Object
arc.math.geom.Ellipse
- All Implemented Interfaces:
Shape2D
A convenient 2D ellipse class, based on the circle class
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfloat
area()
float
Approximates the circumference of thisEllipse
.boolean
contains
(float x, float y) Checks whether or not this ellipse contains the given point.boolean
Checks whether or not this ellipse contains the given point.boolean
int
hashCode()
void
set
(float x, float y, float width, float height) Sets a new position and size for this ellipse.void
void
Sets a new position and size for this ellipse based upon another ellipse.void
setPosition
(float x, float y) Sets the x and y-coordinates of ellipse centersetPosition
(Vec2 position) Sets the x and y-coordinates of ellipse center from aVec2
.setSize
(float width, float height) Sets the width and height of this ellipse
-
Field Details
-
x
public float x -
y
public float y -
width
public float width -
height
public float height
-
-
Constructor Details
-
Ellipse
public Ellipse()Construct a new ellipse with all values set to zero -
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
Costructs a new ellipse- Parameters:
position
- Position vectorwidth
- the width of the ellipseheight
- the height of the ellipse
-
Ellipse
-
Ellipse
Constructs a newEllipse
from the position and radius of aCircle
(since circles are special cases of ellipses).- Parameters:
circle
- The circle to take the values of
-
-
Method Details
-
contains
public boolean contains(float x, float y) Checks whether or not this ellipse contains the given point. -
contains
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
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
-
set
-
setPosition
Sets the x and y-coordinates of ellipse center from aVec2
.- Parameters:
position
- The position vector- Returns:
- this ellipse for chaining
-
setPosition
Sets the x and y-coordinates of ellipse center- Parameters:
x
- The x-coordinatey
- The y-coordinate- Returns:
- this ellipse for chaining
-
setSize
Sets the width and height of this ellipse- Parameters:
width
- The widthheight
- The height- Returns:
- this ellipse for chaining
-
area
public float area() -
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
-
hashCode
public int hashCode()
-