Пример #1
0
        public List<IPrimitiveConditionData> GenerateRules(List<TouchPoint2> points)
        {
            List<IPrimitiveConditionData> returnList = new List<IPrimitiveConditionData>();

            // Do all the possible combinations
            for (int j = 0; j < points.Count - 1; j++)
            {
                //If it's a blob, leave it
                if (!points[j].isFinger)
                {
                    returnList.Add(null);
                    continue;
                }

                var stylusPoints1 = TrigonometricCalculationHelper.removeRedundancy(points[j].Stroke.StylusPoints);
                if (stylusPoints1.Count < 4)  // It's a point
                {
                    returnList.Add(null);
                    continue;
                }

                ValidSetOfTouchPoints line1 = ValidateLine(points[j]);
                if (line1.Count > 0)
                {
                    for (int i = j + 1; i < points.Count; i++)
                    {
                        //Check to see if it is a point
                        var stylusPoints2 = TrigonometricCalculationHelper.removeRedundancy(points[i].Stroke.StylusPoints);
                        if (stylusPoints2.Count == 0)
                            continue;

                        // check to see if the two sets of points are lines
                        ValidSetOfTouchPoints line2 = ValidateLine(points[i]);
                        if (line2.Count == 0)
                            continue;

                        // Considering that they are two lines, the angle will only be check if their edges are  nearby
                        if (!linesTouch(stylusPoints1, stylusPoints2))
                        {
                            returnList.Add(null);
                            continue;
                        }

                        // Calculate slope of each line represented by the two sets of touch points
                        // as the final of a line is usually fuzzy, get the middle points(1/4,3/4), that have a more fixed pattern
                        int avg1 = stylusPoints1.Count;
                        int avg2 = stylusPoints2.Count;

                        double set1Angle = TrigonometricCalculationHelper.GetSlopeBetweenPoints(stylusPoints1[avg1 / 4], stylusPoints1[avg1 * 3 / 4]);
                        double set2Angle = TrigonometricCalculationHelper.GetSlopeBetweenPoints(stylusPoints2[avg2 / 4], stylusPoints2[avg2 * 3 / 4]);

                        double angularDiff = (set1Angle - set2Angle) * 180 / 3.14;

                        if (angularDiff < 0)
                            angularDiff = 180 + angularDiff;

                        if (angularDiff > 180)
                            angularDiff = angularDiff - 180;

                        AngleBetween result = new AngleBetween();
                        result.Gesture1 = (j + 1) + "";
                        result.Gesture2 = (i + 1) + "";
                        result.Min = angularDiff;
                        returnList.Add(result);
                    }
                }
            }

            return returnList;
        }
Пример #2
0
 public void Init(IPrimitiveConditionData ruleData)
 {
     _data = ruleData as AngleBetween;
 }