public static double DistanceAtBestAngle(List <Point> points, Unistroke stroke, double a, double b, double threshold) { var x1 = PointsHelpers.Phi * a + (1.0 - PointsHelpers.Phi) * b; var f1 = DistanceAtAngle(points, stroke, x1); var x2 = (1.0 - PointsHelpers.Phi) * a + PointsHelpers.Phi * b; var f2 = DistanceAtAngle(points, stroke, x2); while (Math.Abs(b - a) > threshold) { if (f1 < f2) { b = x2; x2 = x1; f2 = f1; x1 = Phi * a + (1.0 - Phi) * b; f1 = DistanceAtAngle(points, stroke, x1); } else { a = x1; x1 = x2; f1 = f2; x2 = (1.0 - Phi) * a + Phi * b; f2 = DistanceAtAngle(points, stroke, x2); } } return(Math.Min(f1, f2)); }
public DollarRecognizer AddGesture(Unistroke stroke, bool addReverse = false) { Unistrokes.Add(stroke); if (addReverse) { AddReverseOfStroke(stroke); } return(this); }
private void AddReverseOfStroke(Unistroke stroke) { var reversedPoints = new List <Point>(); for (int i = stroke.OriginalPoints.Count - 1; i >= 0; i--) { reversedPoints.Add(stroke.OriginalPoints[i]); } Unistrokes.Add(new Unistroke(stroke.Name, reversedPoints)); }
public static double DistanceAtAngle(List <Point> points, Unistroke stroke, double radians) { var newpoints = RotateBy(points, radians); return(PathDistance(newpoints, stroke.Points)); }