예제 #1
0
        internal void UpdateToken(InternalToken internalToken)
        {
            this._position = internalToken.Position;
            this._angle = internalToken.Angle;
            this._deltaAngle = internalToken.DeltaAngle;
            this._deltaPosition = internalToken.DeltaPosition;

        }
예제 #2
0
 internal Token(InternalToken internalToken)
 {
     this._id = internalToken.Id;
     this._class = internalToken.Class;
     this._position = internalToken.Position;
     this._angle = internalToken.Angle;
     this._deltaAngle = internalToken.DeltaAngle;
     this._deltaPosition = internalToken.DeltaPosition;
     
 }
예제 #3
0
        public InternalToken IdentifyCluster(Cluster cluster)
        {
            //Start Stop Watch for statistics
            Stopwatch sw = Stopwatch.StartNew();
             
            InternalToken token = null;
            //Cluster identification Algorithm
            Dictionary<int, TouchInput> clusterPoints = cluster.Points;
            TokenMarker[] meanSquaredTokenReferenceSystem;

            /*Ordered indexes of markers 0 => Origin 
            *                            1 => X axis 
            *                            2 => Y axis
            *                            3 => Data
            */
            int[] orderedIndexes = new int[4];

            //Find two furthest apart poits which reppresent the x xis and the y axis markers
            int[] furthestPointIndexes = FindTwoFurthestPoints(clusterPoints.Values.ToArray());
            
            //Gets indexes of two remaing points which reppresent origin and data marker
            int[] originAndDataIndexes = clusterPoints.Where(p => p.Key != furthestPointIndexes[0] && p.Key != furthestPointIndexes[1])
                                                      .Select(z => z.Key).ToArray();

            if(FindOriginIndex(furthestPointIndexes, originAndDataIndexes, clusterPoints, ref orderedIndexes))
            {
                //Origin Marker Identified and stored in orderedIndexes[0]
                if (DistinguishAxisVectors(furthestPointIndexes, clusterPoints, ref orderedIndexes))
                {
                    //Axis markers have been correctly identified
                    //Remaing point is Data Marker
                    orderedIndexes[3] = clusterPoints.Where(p => p.Key != orderedIndexes[0] && p.Key != orderedIndexes[1] && p.Key != orderedIndexes[2])
                                                     .Select(z => z.Key).Single();

                    //Compute Mean Square Problem for reference System

                    Dictionary<int, TokenMarker> markers = TokenUtils.ConvertTouchInputToMarkers(orderedIndexes, clusterPoints);

                    meanSquaredTokenReferenceSystem = TokenUtils.MeanSquareOrthogonalReferenceSystem(markers[orderedIndexes[0]],
                                                                                                     markers[orderedIndexes[1]],
                                                                                                     markers[orderedIndexes[2]],
                                                                                                     TokenManager.CurrentTokenType.DistanceOriginAxisMarkersPX);
                    //Create Token
                    token = new InternalToken(cluster.Hash, markers);
                    token.SetMeanSquareReferenceSystem(meanSquaredTokenReferenceSystem);
                }
                else
                    throw (new TokenAxisNotDistinguishedException("Could not Distinguish Axis"));
            }
            else
            {
                //throw (new NoOrthogonalVectorsFoundException("Could not find Orthogonal Vectors"));
                //No orthogonal vectors found thus no origin, failed identification
                //For the moment return null, in case consider doing second iteration on second maximum
                sw.Stop();
                TokenStatistics.Instance.SetTokenIdentificationTime(sw.ElapsedMilliseconds);
                return token;
            }
            sw.Stop();
            TokenStatistics.Instance.SetTokenIdentificationTime(sw.ElapsedMilliseconds);
            return token;
            
        }
예제 #4
0
 private bool UpdateGreaterThanThreshold(InternalToken token)
 {
     if (Math.Abs(token.DeltaPosition.x) > TokenUpdateTranslationThreshold || Math.Abs(token.DeltaPosition.y) > TokenUpdateTranslationThreshold ||
        Math.Abs(token.DeltaAngle) > TokenUpdateRotationThreshold)
         return true;
     else
         return false;
 }
예제 #5
0
 internal static void AddToken(InternalToken token)
 {
     _tokens[token.Id] = new Token(token);
 }