public static SpssCase AddTechniqueData(SpssCase gestureAttempt, GestureType type, Attempt attempt)
        {
            gestureAttempt[$"{type}Efficiency"] = attempt.Time.TotalSeconds;
            gestureAttempt[$"{type}Effectiveness"] = attempt.Hit;
            gestureAttempt[$"{type}Accuracy"] = MathHelper.GetDistance(attempt);
            gestureAttempt[$"{type}TargetSize"] = attempt.Size;
            gestureAttempt[$"{type}Direction"] = attempt.Direction;

            return gestureAttempt;
        }
Beispiel #2
0
        public static Tuple<double, double> GetXYDistance(Attempt attempt)
        {
            double scale = GetScale(attempt.Size);
            double x = attempt.TargetCell.X * scale, y = attempt.TargetCell.Y * scale;
            double xDistance = 0, yDistance = 0;

            if (attempt.Pointer.X < x) {
                xDistance = x - attempt.Pointer.X;
            }
            else if (attempt.Pointer.X > x + scale) {
                xDistance = attempt.Pointer.X - (x + scale);
            }

            if (attempt.Pointer.Y < y) {
                yDistance = y - attempt.Pointer.Y;
            }
            else if (attempt.Pointer.Y > y + scale) {
                yDistance = attempt.Pointer.Y - (y + scale);
            }

            return new Tuple<double, double>(xDistance, yDistance);
        }
Beispiel #3
0
        public static SpssCase AddTechniqueDataLong(SpssCase gestureAttempt, GestureType type, Attempt attempt)
        {
            gestureAttempt[$"Efficiency"]    = attempt.Time.TotalSeconds;
            gestureAttempt[$"Effectiveness"] = attempt.Hit;
            gestureAttempt[$"Accuracy"]      = MathHelper.GetDistance(attempt);
            gestureAttempt[$"TargetSize"]    = attempt.Size;
            gestureAttempt[$"Direction"]     = attempt.Direction;
            gestureAttempt[$"AttemptNumber"] = attempt.AttemptNumber;

            return(gestureAttempt);
        }
Beispiel #4
0
 public static double GetDistance(Attempt attempt)
 {
     return(attempt.Source == DataSource.Accuracy ? DistanceToTargetCenter(attempt) : DistanceToTargetCell(attempt));
 }
Beispiel #5
0
        private static double DistanceToTargetCell(Attempt attempt)
        {
            if(attempt.Hit) { return 0; }
            double scale = GetScale(attempt.Size);
            List<Tuple<Point, Point>> lineSegments = new List<Tuple<Point, Point>>();
            Point t = new Point(attempt.TargetCell.X * scale, attempt.TargetCell.Y * scale);
            Point u = new Point(t.X, t.Y + scale);
            Point v = new Point(t.X + scale, t.Y + scale);
            Point w = new Point(t.X + scale, t.Y);
            lineSegments.Add(new Tuple<Point, Point>(t, u));
            lineSegments.Add(new Tuple<Point, Point>(t, w));
            lineSegments.Add(new Tuple<Point, Point>(u, v));
            lineSegments.Add(new Tuple<Point, Point>(v, w));
            List<double> distances = new List<double>();
            foreach (var line in lineSegments) {
                distances.Add(DistanceToSegment(attempt.Pointer, line.Item1, line.Item2));
            }

            return distances.Min();
        }
Beispiel #6
0
 public static double GetDistance(Attempt attempt)
 {
     return attempt.Source == DataSource.Accuracy ? DistanceToTargetCenter(attempt) : DistanceToTargetCell(attempt);
 }
Beispiel #7
0
 private static double DistanceToTargetCenter(Attempt attempt)
 {
     double scale = GetScale(attempt.Size);
     Point c = new Point((attempt.TargetCell.X * scale) + (scale * 0.5), (attempt.TargetCell.Y * scale) + (scale * 0.5));
     return Math.Sqrt(DistanceSquare(c, attempt.Pointer));
 }
 public static void UpdateAttempt(Attempt attempt)
 {
     UpdateAttempt(new List<Attempt>() {attempt});
 }
Beispiel #9
0
        public Test(int id, DataSource source)
            : this()
        {
            string path = DataGenerator.TestFileDirectory(source) + id + ".test";
            StreamReader sr = new StreamReader(path);
            ID = path.Split('/').Last().Split('.')[0];

            TimeSpan attemptTime = default(TimeSpan);

            using (sr) {
                string line = "";
                GridSize size = GridSize.Large;
                GestureType type = GestureType.Pinch;
                GestureDirection direction = GestureDirection.Push;
                TimeSpan currentTime = TimeSpan.Zero;
                int count = 1;
                while ((line = sr.ReadLine()) != null) {
                    if(line == "") { continue; }
                    string[] time = line.Trim().Split('[', ']')[1].Split(':');
                    TimeSpan entryTime = new TimeSpan(Int32.Parse(time[0]), Int32.Parse(time[1]), Int32.Parse(time[2]));
                    if (line.Contains("Started new gesture test.")) {

                        string tobesearched = "Type: ";
                        string toBefound = line.Substring(line.IndexOf(tobesearched) + tobesearched.Length).Split(' ')[0];
                        switch (toBefound) {
                            case "Throw": type = GestureType.Throw; break;
                            case "Tilt": type = GestureType.Tilt; break;
                            case "Swipe": type = GestureType.Swipe; break;
                            case "Pinch": type = GestureType.Pinch; break;
                        }

                        tobesearched = "Direction: ";
                        toBefound = line.Substring(line.IndexOf(tobesearched) + tobesearched.Length).Split(' ')[0];
                        direction = toBefound == "Push" ? GestureDirection.Push : GestureDirection.Pull;
                        if (!Attempts.ContainsKey(type)) {
                            Attempts.Add(type, new List<Attempt>());
                        }

                        currentTime = entryTime;
                    }
                    else if (line.Contains("Grid height: 10")) {
                        size = GridSize.Small;
                    }
                    else if (line.Contains("Grid height: 5")) {
                        size = GridSize.Large;
                    }
                    else if (line.Contains("Target")) {
                        if (line.Contains("JL: NA")) {
                            currentTime = entryTime;
                            continue;
                        }
                        attemptTime = entryTime - currentTime;
                        currentTime = entryTime;

                        Attempt attempt = new Attempt(ID, count++, line, attemptTime, size, direction, type, source);
                        Attempts[type].Add(attempt);
                    }
                }
            }

            if(source == DataSource.Old) {
                FixTest();
            }
        }