diff --git a/BoundingBox.cs b/BoundingBox.cs
index 01088e1..9d2f037 100644
--- a/BoundingBox.cs
+++ b/BoundingBox.cs
@@ -6,13 +6,19 @@ namespace BoundingBox
public class BoundingBox2
{
+ ///
+ /// Vector containing the lowest X and Y coordinates contained in the bounding box.
+ ///
public Vector2 Min;
+ ///
+ /// Vector containing the highest X and Y coordinates contained in the bounding box.
+ ///
public Vector2 Max;
- public Vector2 Center => ;
+ public Vector2 Center => (Max + Min) * 0.5f;
- public Vector2 Size =>;
+ public Vector2 Size => Max - Min;
public BoundingBox2(Vector2 min, Vector2 max)
{
@@ -22,21 +28,34 @@ namespace BoundingBox
public bool Contains(Vector2 position)
{
-
+ return Min.X <= position.X && position.X <= Max.X && Min.Y <= position.Y && position.Y <= Max.Y;
}
public IntersectionType Intersects(BoundingBox2 other)
{
+ if (Min.X <= other.Min.X && other.Max.X <= Max.X && Min.Y <= other.Min.Y && other.Max.Y <= Max.Y)
+ {
+ return IntersectionType.Contains;
+ }
+ if ((other.Max.X <= Min.X || Max.X <= other.Min.X) && (other.Max.Y <= Min.Y || Max.Y <= other.Min.Y))
+ {
+ return IntersectionType.Disjoint;
+ }
+ return IntersectionType.Intersects;
}
public void Translate(Vector2 translation)
{
-
+ Min += translation;
+ Max += translation;
}
public void Expand(float expansion)
{
-
+ Min.X -= expansion;
+ Min.Y -= expansion;
+ Max.X += expansion;
+ Max.Y += expansion;
}
}
}