refactor: AABB
This commit is contained in:
parent
8ccebaa8fb
commit
5c185a664c
|
@ -4,14 +4,11 @@ namespace Syntriax.Engine.Physics2D.Primitives;
|
||||||
|
|
||||||
public record AABB(Vector2D LowerBoundary, Vector2D UpperBoundary)
|
public record AABB(Vector2D LowerBoundary, Vector2D UpperBoundary)
|
||||||
{
|
{
|
||||||
public bool Overlaps(Vector2D point)
|
public static bool ApproximatelyEquals(AABB left, AABB right)
|
||||||
=> point.X >= LowerBoundary.X && point.X <= UpperBoundary.X &&
|
=> left.LowerBoundary.ApproximatelyEquals(right.LowerBoundary) && left.UpperBoundary.ApproximatelyEquals(right.UpperBoundary);
|
||||||
point.Y >= LowerBoundary.Y && point.Y <= UpperBoundary.Y;
|
}
|
||||||
|
|
||||||
public bool Overlaps(AABB other)
|
public static class AABBExtensions
|
||||||
=> LowerBoundary.X <= other.UpperBoundary.X && UpperBoundary.X >= other.LowerBoundary.X &&
|
{
|
||||||
LowerBoundary.Y <= other.UpperBoundary.Y && UpperBoundary.Y >= other.LowerBoundary.Y;
|
public static bool ApproximatelyEquals(this AABB left, AABB right) => AABB.ApproximatelyEquals(left, right);
|
||||||
|
|
||||||
public bool ApproximatelyEquals(AABB other)
|
|
||||||
=> LowerBoundary.ApproximatelyEquals(other.LowerBoundary) && UpperBoundary.ApproximatelyEquals(other.UpperBoundary);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue