Selaa lähdekoodia

added toCircle

Nicolas Cannasse 4 vuotta sitten
vanhempi
commit
aff49de9b6
1 muutettua tiedostoa jossa 9 lisäystä ja 0 poistoa
  1. 9 0
      h2d/col/Bounds.hx

+ 9 - 0
h2d/col/Bounds.hx

@@ -342,6 +342,15 @@ class Bounds {
 	public function toString() : String {
 		return "{" + getMin() + "," + getSize() + "}";
 	}
+	
+	/**
+		Returns the bounding circle which includes all the bounds.
+	**/
+	public inline function toCircle() {
+		var dx = xMax - xMin;
+		var dy = yMax - yMin;
+		return new Circle((xMin + xMax) * 0.5, (yMin + yMax) * 0.5, Math.sqrt(dx * dx + dy * dy) * 0.5);
+	}
 
 	/**
 		Returns a new Bounds instance from given rectangle.