private void generateSmallestEnclosingCircles() { var equiDistantStrokePoints = interpolatedStrokes.Select(s => LinearInterpolation.getEquidistantPoints(s, nAreas)).ToArray(); Areas = Enumerable.Range(0, nAreas).Select( a => new SmallestEnclosingCircle(equiDistantStrokePoints.Select(points => points[a])) ).ToArray(); }
public override Observation[] getSymbolTrace(BaseTrajectory s) { int current_stroke = s.TrajectoryPoints.First().StrokeNum; var accumulate = new List <TrajectoryPoint>(); var gesture_AreaPoints = new List <TrajectoryPoint[]>(); foreach (var point in s.TrajectoryPoints) { if (point.StrokeNum == current_stroke) { accumulate.Add(point); } else { var trajectory = new LinearInterpolation(accumulate.ToArray()); gesture_AreaPoints.Add(LinearInterpolation.getEquidistantPoints(trajectory, nAreas)); accumulate.Clear(); current_stroke = point.StrokeNum; } } gesture_AreaPoints.Add(LinearInterpolation.getEquidistantPoints(new LinearInterpolation(accumulate.ToArray()), nAreas)); var symbolTrace = new Observation[Areas.Length + gesture_AreaPoints.Count]; int counter = 0; int stroke_counter = 0; foreach (var fStroke in gesture_AreaPoints) { var Areas_fraction = Areas.Skip(stroke_counter * fStroke.Length).Take(nAreas); var query = fStroke.Zip(Areas_fraction, (p, a) => { var sym = a.CreateSymbol(p); if (sym == null) { return(null); } string symbol = "S" + ID + "_" + sym; return(new Observation(symbol, p.Time)); }); //GestureStart symbol var startO = new Observation("GestureStart", s.TrajectoryPoints[0].Time); foreach (var single_observation in SingleItemAsEnumerable(startO).Concat(query.TakeWhile(o => o != null)).ToArray()) { symbolTrace[counter] = single_observation; counter++; } stroke_counter++; } //wurden alle Areas erwischt? if (symbolTrace.Length < Areas.Length) { return(null); } return(symbolTrace); }
public override Observation[] getSymbolTrace(BaseTrajectory s) { var strokeInterpolation = (translationInvariant) ? new LinearInterpolation(s.getInvariantPoints()) : new LinearInterpolation(s.TrajectoryPoints); var areaPoints = LinearInterpolation.getEquidistantPoints(strokeInterpolation, Areas.Length); int counter = 1; var query = areaPoints.Zip(Areas, (p, a) => { string sym = "S" + ID + "_A"; long time; if (a.PointInArea(p.X, p.Y)) { sym += counter++ + "_Hit"; time = p.Time; } else if (a.PointInToleranceArea(p.X, p.Y)) { sym += counter++ + "_Tolerance"; time = p.Time; } else { return(null); } return(new Observation(sym, time)); }); //GestureStart symbol var startO = new Observation("GestureStart", s.TrajectoryPoints[0].Time); var symbolTrace = SingleItemAsEnumerable(startO).Concat(query.TakeWhile(o => o != null)).ToArray(); //wurden alle Areas erwischt? if (symbolTrace.Length < Areas.Length) { return(null); } return(symbolTrace); }
public FixedAreaNumberStrokeMap(BaseTrajectory[] srcStrokes) : base(srcStrokes) { int current_stroke = 0; int total_strokes = srcStrokes.First().TrajectoryPoints.Last().StrokeNum; var accumulate = new List <TrajectoryPoint>(); var gesture = new List <TrajectoryPoint[][]>(); var gesture_equidistant = new List <TrajectoryPoint[]>(); foreach (var execution in srcStrokes) { foreach (var point in execution.TrajectoryPoints) { if (point.StrokeNum == current_stroke) { accumulate.Add(point); } else { var trajectory = new LinearInterpolation(accumulate.ToArray()); gesture_equidistant.Add(LinearInterpolation.getEquidistantPoints(trajectory, nAreas)); accumulate.Clear(); current_stroke++; if (current_stroke > total_strokes) { gesture.Add(gesture_equidistant.ToArray()); gesture_equidistant.Clear(); current_stroke = 0; } } } } gesture_equidistant.Add(LinearInterpolation.getEquidistantPoints(new LinearInterpolation(accumulate.ToArray()), nAreas)); gesture.Add(gesture_equidistant.ToArray()); int total_areas = nAreas * (total_strokes + 1); Areas = new Area[total_areas]; Strokes = total_strokes + 1; List <TrajectoryPoint>[] arrayList = new List <TrajectoryPoint> [total_areas]; for (int i = 0; i < total_areas; i++) { arrayList[i] = new List <TrajectoryPoint>(); } foreach (var gesture_stroke in gesture) { int counter = 0; for (int b = 0; b <= total_strokes; b++) { for (int a = 0; a < nAreas; a++) { arrayList[counter].Add(gesture_stroke[b][a]); counter++; } } } for (int a = 0; a < total_areas; a++) { Areas[a] = createArea(a, arrayList[a]); } }