Engine-Pong/Game/Physics2D/Primitives/AABB.cs

18 lines
740 B
C#
Raw Normal View History

2024-01-23 12:16:58 +03:00
using Syntriax.Engine.Core;
2023-12-07 10:55:49 +03:00
namespace Syntriax.Engine.Physics2D.Primitives;
2024-01-23 12:16:58 +03:00
public record AABB(Vector2D LowerBoundary, Vector2D UpperBoundary)
2023-12-07 10:55:49 +03:00
{
2024-01-23 12:16:58 +03:00
public bool Overlaps(Vector2D point)
2023-12-07 10:55:49 +03:00
=> point.X >= LowerBoundary.X && point.X <= UpperBoundary.X &&
point.Y >= LowerBoundary.Y && point.Y <= UpperBoundary.Y;
2023-12-07 11:14:18 +03:00
public bool Overlaps(AABB other)
=> LowerBoundary.X <= other.UpperBoundary.X && UpperBoundary.X >= other.LowerBoundary.X &&
LowerBoundary.Y <= other.UpperBoundary.Y && UpperBoundary.Y >= other.LowerBoundary.Y;
public bool ApproximatelyEquals(AABB other)
=> LowerBoundary.ApproximatelyEquals(other.LowerBoundary) && UpperBoundary.ApproximatelyEquals(other.UpperBoundary);
2023-12-07 10:55:49 +03:00
}