public bool Intersects(AABB2D b) { return(!(Right > b.Left || Left < b.Right || Top > b.Bottom || Bottom < b.Top)); }
public static AABB2DIntersectionResult IntersectMovingAABBToAABB(AABB2D a, Vector2 movement, AABB2D b) { LineSegment2D segment = new(a.Center, a.Center + movement); AABB2D other = b.Inflate(a.Size); return(IntersectLineSegmentToAABB(segment, other)); }
public AABB2DIntersectionResult(Vector2 position, Vector2 movement, AABBFace face, AABB2D other) { Position = position; Movement = movement; Face = face; Other = other; Normal = Face switch { AABBFace.Left => - Vector2.UnitX, AABBFace.Right => Vector2.UnitX, AABBFace.Bottom => - Vector2.UnitY, AABBFace.Top => Vector2.UnitY, _ => Vector2.One.Normalized() }; } }