19 lines
649 B
C#
19 lines
649 B
C#
|
using Syntriax.Engine.Core;
|
||
|
|
||
|
namespace Syntriax.Engine.Physics2D.Primitives;
|
||
|
|
||
|
public record Circle(Vector2D Position, float Radius)
|
||
|
{
|
||
|
public bool Intersects(Circle other)
|
||
|
{
|
||
|
float distanceSquared = (Position - other.Position).LengthSquared();
|
||
|
float radiusSumSquared = Radius * Radius + other.Radius * other.Radius;
|
||
|
|
||
|
return distanceSquared < radiusSumSquared;
|
||
|
}
|
||
|
|
||
|
public bool Overlaps(Vector2D point) => (Position - point).LengthSquared() <= Radius * Radius;
|
||
|
public bool ApproximatelyEquals(Circle other)
|
||
|
=> Position.ApproximatelyEquals(other.Position) && Radius.ApproximatelyEquals(other.Radius);
|
||
|
}
|