Esempio n. 1
0
        public IStats Analyze(Mouse baseline, Mouse subject, IEnumerable <Move> moves)
        {
            var stats = new PointStats
                            (StatDescription
                            , DefaultFactor
                            , -Math.PI
                            , Math.PI
                            , 0.1
                            );

            const double threshold = DisplacementInterval * DisplacementInterval;
            var          baseD     = Vec.Zero;
            var          subjD     = Vec.Zero;
            var          crossTime = TimeSpan.MaxValue;

            foreach (var move in moves)
            {
                if (move.Time > crossTime)
                {
                    if (baseD.MagnitudeSquared > threshold && subjD.MagnitudeSquared > threshold)
                    {
                        var angleDelta = subjD.Angle - baseD.Angle;
                        // normalize to range [-pi, pi]
                        angleDelta = Math.Atan2(Math.Sin(angleDelta), Math.Cos(angleDelta));
                        stats.AddPoint(crossTime, angleDelta);
                    }
                    // Reset trackers.
                    baseD     = Vec.Zero;
                    subjD     = Vec.Zero;
                    crossTime = TimeSpan.MaxValue;
                }
                if (move.Mouse == baseline)
                {
                    baseD += move.D;
                }
                else if (move.Mouse == subject)
                {
                    subjD += move.D;
                }
                if (baseD.MagnitudeSquared >= threshold &&
                    subjD.MagnitudeSquared >= threshold)
                {
                    // We've crossed the threshold - mark the time.
                    // We'll keep eating moves until we find one later than this timestamp then add a datapoint.
                    crossTime = move.Time;
                }
            }

            return(stats);
        }
Esempio n. 2
0
        public IStats Analyze(Mouse baseline, Mouse subject, IEnumerable <Move> moves)
        {
            var stats = new PointStats
                            (StatDescription
                            , DefaultFactor
                            , 0.0
                            , 4.0
                            , 1.0
                            , 0.1
                            );

            var baseD     = 0.0;
            var subjD     = 0.0;
            var crossTime = TimeSpan.MaxValue;

            foreach (var move in moves)
            {
                if (move.Time > crossTime)
                {
                    if (Math.Abs(baseD) > 0.001)
                    {
                        var ratio = subjD / baseD;
                        stats.AddPoint(crossTime, ratio);
                    }
                    // Reset trackers.
                    baseD     = 0.0;
                    subjD     = 0.0;
                    crossTime = TimeSpan.MaxValue;
                }
                if (move.Mouse == baseline)
                {
                    baseD += move.D.Magnitude;
                }
                else if (move.Mouse == subject)
                {
                    subjD += move.D.Magnitude;
                }
                if (baseD >= DistanceInterval &&
                    subjD >= DistanceInterval)
                {
                    // We've crossed the threshold - mark the time.
                    // We'll keep eating moves until we find one later than this timestamp then add a datapoint.
                    crossTime = move.Time;
                }
            }

            return(stats);
        }
Esempio n. 3
0
            private void CompareMovementFromDeadStop(TimeSpan moveTime, MouseLagProcessor otherMouse)
            {
                if (otherMouse._lastMoveFromDeadStop == null)
                {
                    return;
                }
                var ourDelay = moveTime - otherMouse._lastMoveFromDeadStop.Value;

                if (ourDelay >= DeadStop)
                {
                    return;                       // this is from an older move
                }
                var subjectDelay =
                    _isBaseline ? -ourDelay : ourDelay;

                _stats.AddPoint(moveTime, subjectDelay.TotalMilliseconds);
            }
Esempio n. 4
0
        public IStats Analyze(Mouse baseline, Mouse subject, IEnumerable <Move> moves)
        {
            var stats = new PointStats
                            (StatDescription
                            , DefaultFactor
                            , 0.0
                            , 100000.0
                            , 10000.0
                            , 1000.0
                            );

            TimeSpan?start    = null;
            var      distance = 0.0;

            foreach (var move in moves)
            {
                if (move.Mouse != baseline)
                {
                    continue;
                }
                if (start == null)
                {
                    start = move.Time;
                }
                distance += move.D.Magnitude;
                if (distance >= DistanceInterval)
                {
                    var time  = move.Time - start.Value;
                    var speed = distance / time.TotalSeconds;
                    stats.AddPoint(move.Time, speed);
                    distance = 0.0;
                    start    = move.Time;
                }
            }
            return(stats);
        }