2023-12-07 10:55:49 +03:00
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
|
|
|
namespace Syntriax.Engine.Physics2D.Primitives;
|
|
|
|
|
|
|
|
public record Circle(Vector2 Position, float Radius)
|
|
|
|
{
|
2023-12-07 11:14:18 +03:00
|
|
|
public bool Intersects(Circle other)
|
2023-12-07 10:55:49 +03:00
|
|
|
{
|
2023-12-07 11:14:18 +03:00
|
|
|
float distanceSquared = (Position - other.Position).LengthSquared();
|
|
|
|
float radiusSumSquared = Radius * Radius + other.Radius * other.Radius;
|
2023-12-07 10:55:49 +03:00
|
|
|
|
|
|
|
return distanceSquared < radiusSumSquared;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool Overlaps(Vector2 point) => (Position - point).LengthSquared() <= Radius * Radius;
|
2023-12-07 11:14:18 +03:00
|
|
|
public bool ApproximatelyEquals(Circle other)
|
|
|
|
=> Position.ApproximatelyEquals(other.Position) && Radius.ApproximatelyEquals(other.Radius);
|
2023-12-07 10:55:49 +03:00
|
|
|
}
|