using TraceCad.Core.Geometry;

namespace TraceCad.Core.Model;

public sealed record ArcEntity(
    Guid Id,
    string Layer,
    Point2 Center,
    double Radius,
    double StartAngleDeg,
    double EndAngleDeg,
    bool IsClockwise) : Entity(Id, Layer)
{
    public Point2 StartPoint => PointAtAngle(StartAngleDeg);

    public Point2 EndPoint => PointAtAngle(EndAngleDeg);

    public override IEnumerable<Point2> SnapPoints
    {
        get
        {
            yield return StartPoint;
            yield return EndPoint;
            yield return Center;
        }
    }

    public Point2 PointAtAngle(double angleDeg)
    {
        var radians = angleDeg * Math.PI / 180.0;
        return new Point2(Center.X + (Math.Cos(radians) * Radius), Center.Y + (Math.Sin(radians) * Radius));
    }
}
