Ejemplo n.º 1
0
        public GestureState TestMotion(int index, PointF start, PointF end)
        {
            if (index >= Points.Count - 1)
            {
                return GestureState.Complete;
            }

            var previousPoint = Points[index];
            var nextPoint = Points[index + 1];

            var previousRadiusSq = previousPoint.threshold * previousPoint.threshold;
            var endDX = end.X - previousPoint.X;
            var endDY = end.Y - previousPoint.Y;
            var endRadiusSq = (endDX * endDX) + (endDY * endDY);

            var quad = new GestureQuad(previousPoint, nextPoint);

            // first check for point completion
            if (TestCrossing(quad, start, end))
            {
                if (index == Points.Count - 2) return GestureState.Complete;
                else return GestureState.Advance;
            }

            // must be inside the quad or the starting circle
            if (!(endRadiusSq <= previousRadiusSq || quad.Test(end))) return GestureState.Fail;

            return GestureState.OK;
        }