--- /dev/null
+\r
+package com.badlogic.gdx.math;\r
+\r
+import java.io.Serializable;\r
+\r
+import com.badlogic.gdx.math.Vector2;\r
+\r
+/** A convenient 2D ellipse class, based on the circle class\r
+ * @author tonyp7 */\r
+public class Ellipse implements Serializable {\r
+\r
+ public float x, y;\r
+ public float width, height;\r
+ private float halfWidth, halfHeight;\r
+\r
+ private static final long serialVersionUID = 7381533206532032099L;\r
+\r
+ /** Construct a new ellipse with all values set to zero */\r
+ public Ellipse () {\r
+\r
+ }\r
+\r
+ public Ellipse (float x, float y, float width, float height) {\r
+ this.x = x;\r
+ this.y = y;\r
+ this.width = width;\r
+ this.height = height;\r
+ }\r
+\r
+ public Ellipse (Vector2 position, float width, float height) {\r
+ this.x = position.x;\r
+ this.y = position.y;\r
+ this.width = width;\r
+ this.height = height;\r
+ }\r
+\r
+ public boolean contains (float x, float y) {\r
+ x = x - this.x;\r
+ y = y - this.y;\r
+ halfWidth = width * 0.5f;\r
+ halfHeight = height * 0.5f;\r
+\r
+ return (x * x) / (halfWidth * halfWidth) + (y * y) / (halfHeight * halfHeight) <= 1.0f;\r
+ }\r
+\r
+ public boolean contains (Vector2 point) {\r
+ return contains(point.x, point.y);\r
+ }\r
+\r
+ public void set (float x, float y, float width, float height) {\r
+ this.x = x;\r
+ this.y = y;\r
+ this.width = width;\r
+ this.height = height;\r
+ }\r
+\r
+}\r