using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using bbiwarg.Utility;

namespace bbiwarg.Detectors.Fingers
{
    class FingerSliceTrail
    {
        public List<FingerSlice> Slices { get; private set; }
        public FingerSlice Start { get { return Slices[0]; } }
        public FingerSlice End { get { return Slices[Slices.Count - 1]; } }
        public int NumSlices { get { return Slices.Count; } }
        public LineSegment2D LineSegment { get { return new LineSegment2D(End.Mid, Start.Mid); } }

        public FingerSliceTrail(FingerSlice slice)
        {
            Slices = new List<FingerSlice>();
            Slices.Add(slice);
        }

        public void addSlice(FingerSlice slice)
        {
            Slices.Add(slice);
        }

        public Vector2D getEndDirection() {
            int numSlicesToInnerEnd = 5;
            int innerEndIndex = Math.Max(0, NumSlices - numSlicesToInnerEnd);

            return (End.Mid - Slices[innerEndIndex].Mid).normalize();
        }
    }
}
