Ejemplo n.º 1
0
        private bool IsClosedLoop(TouchPoint2 point)
        {
            double length = TrigonometricCalculationHelper.CalculatePathLength(point);

            if (length < 50)
                return false;
            // Check the distance between start and end point
            if (point.Stroke.StylusPoints.Count > 1)
            {
                StylusPoint firstPoint = point.Stroke.StylusPoints[0];
                StylusPoint lastPoint = point.Stroke.StylusPoints[point.Stroke.StylusPoints.Count - 1];

                double distance = TrigonometricCalculationHelper.GetDistanceBetweenPoints(firstPoint, lastPoint);
                Correlation recognizer = new Correlation(point);
                if (Math.Abs(recognizer.RSquared) < 0.1)
                {
                    if (distance < threshHold)
                    {
                        return true;
                    }
                }

            }
            return false;
        }
Ejemplo n.º 2
0
 private ValidSetOfTouchPoints ValidateLine(TouchPoint2 points)
 {
     ValidSetOfTouchPoints ret = new ValidSetOfTouchPoints();
     Correlation recognizer = new Correlation(points);
     if (Math.Abs(recognizer.RSquared) > .1)
     {
         ret.Add(points);
     }
     return ret;
 }
Ejemplo n.º 3
0
        private ValidSetOfTouchPoints ValidateBox(TouchPoint2 points)
        {
            ValidSetOfTouchPoints output = new ValidSetOfTouchPoints();
            int length = points.Stroke.StylusPoints.Count;
            if (length < 1)
            {
                return output;
            }

            List<string> slopes = new List<string>();
            TouchPoint2 newPoints = points.GetEmptyCopy();

            for (int i = 0; i < length - 1; i++)
            {
                var point1 = points.Stroke.StylusPoints[i];
                var point2 = points.Stroke.StylusPoints[i + 1];
                double slope = TrigonometricCalculationHelper.GetSlopeBetweenPoints(point1, point2);
                double distance = TrigonometricCalculationHelper.GetDistanceBetweenPoints(point1, point2);
                string stringSlope = TouchPointExtensions.SlopeToDirection(slope);
                if (distance > 0)
                {
                    newPoints.Stroke.StylusPoints.Add(point1);
                    Correlation recognizer = new Correlation(newPoints);
                    if (Math.Abs(recognizer.RSquared) < TOLERANCE + 0.15)
                    {
                        int linelength = newPoints.Stroke.StylusPoints.Count;
                        double lineSlope = TrigonometricCalculationHelper.GetSlopeBetweenPoints(newPoints.Stroke.StylusPoints[1],
                            newPoints.Stroke.StylusPoints[linelength - 1]);
                        string lineStringSlope = TouchPointExtensions.SlopeToDirection(lineSlope);
                        slopes.Add(lineStringSlope);
                        newPoints = newPoints.GetEmptyCopy();
                    }
                }
            }
            RectangleParser parser = new RectangleParser();
            bool hasRect = parser.Advance(slopes);
            if (hasRect)
            {
                output.Add(points);
            }
            return output;
        }