feat: Initial Physics Code From Previous Repo
This commit is contained in:
17
Engine.Physics2D/Primitives/AABB.cs
Normal file
17
Engine.Physics2D/Primitives/AABB.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Syntriax.Engine.Core;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D.Primitives;
|
||||
|
||||
public record AABB(Vector2D LowerBoundary, Vector2D UpperBoundary)
|
||||
{
|
||||
public bool Overlaps(Vector2D point)
|
||||
=> point.X >= LowerBoundary.X && point.X <= UpperBoundary.X &&
|
||||
point.Y >= LowerBoundary.Y && point.Y <= UpperBoundary.Y;
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user