コード例 #1
0
ファイル: InternalToken.cs プロジェクト: CGVGroup/ToMMI
        public bool ComputeTokenClass(ClassComputeReferenceSystem refSystem, ClassComputeDimension dimension)
        {
            float   tokenAngleRad;
            Vector2 dataOriginalPosition;
            Vector2 originPosition;

            if (refSystem == ClassComputeReferenceSystem.Regular)
            {
                tokenAngleRad  = this._angle * Mathf.Deg2Rad;
                originPosition = typeMarkers[MarkerType.Origin].Position;
            }
            else
            {
                tokenAngleRad  = this.meanSquaredTokenAngle * Mathf.Deg2Rad;
                originPosition = this.meanSquaredTokenReferenceSystem[0].Position;
            }

            dataOriginalPosition = typeMarkers[MarkerType.Data].Position;

            Vector2 dataCoordinates = TokenUtils.ComputeRotoTranslation(dataOriginalPosition, originPosition, tokenAngleRad);

            dataGridIndexes = CalculateDataGridIndexes(dataCoordinates, dimension);

            this._class = TokenManager.CurrentTokenType.GetTokenClass(dataGridIndexes[0], dataGridIndexes[1]);

            if (this._class != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
ファイル: TokenManager.cs プロジェクト: CGVGroup/ToMMI
        public void Initialize()
        {
            tokenStatistics = TokenStatistics.Instance;

            switch (TokensEngine.Pars.Type)
            {
            case TokensEngineProperties.TOKEN3x3:
                CurrentTokenType = (new Token3x3());
                break;

            case TokensEngineProperties.TOKEN4x4:
                CurrentTokenType = (new Token4x4());
                break;

            case TokensEngineProperties.TOKEN5x5:
                CurrentTokenType = (new Token5x5());
                break;
            }

            ClusterManager.Instance.Initialize();
            ClusterManager.Instance.SetClusterDistThreshold(CurrentTokenType.TokenDiagonalPX);

            if (TokensEngine.Pars.MeanSquare)
            {
                ClassComputeRefSystem = ClassComputeReferenceSystem.MeanSqure;
            }
            else
            {
                ClassComputeRefSystem = ClassComputeReferenceSystem.Regular;
            }

            ContinuousMeanSquare = TokensEngine.Pars.ContinuousMeanSquare;

            if (TokensEngine.Pars.ComputePixels == TokensEngineProperties.PIXELS)
            {
                ComputeDimension = ClassComputeDimension.Pixels;
            }
            else
            {
                ComputeDimension = ClassComputeDimension.Centimeters;
            }


            TokenUpdateTranslationThreshold = (TokensEngine.Pars.TranslationThr);
            TokenUpdateRotationThreshold    = (TokensEngine.Pars.RotationThr);

            // listen to updated cluster events
            ClusterManager.Instance.ClustersUpdateEvent += OnClustersUpdated;
        }
コード例 #3
0
ファイル: InternalToken.cs プロジェクト: CGVGroup/ToMMI
        private int[] CalculateDataGridIndexes(Vector2 dataCoordinates, ClassComputeDimension dimension)
        {
            int[] result = new int[2];
            float xCoord;
            float yCoord;

            if (dimension == ClassComputeDimension.Pixels)
            {
                xCoord = (dataCoordinates.x - TokenManager.CurrentTokenType.DataMarkerOriginPositionPX) / TokenManager.CurrentTokenType.DataGridMarkersStepPX;
                yCoord = (dataCoordinates.y - TokenManager.CurrentTokenType.DataMarkerOriginPositionPX) / TokenManager.CurrentTokenType.DataGridMarkersStepPX;
            }
            else
            {
                Vector2 dataCoordinatesCM = new Vector2(TokensEngine.PixelsToCm(dataCoordinates.x), TokensEngine.PixelsToCm(dataCoordinates.y));
                xCoord = (dataCoordinatesCM.x - TokenManager.CurrentTokenType.DataMarkerOriginPositionCM) / TokenAttributes.TOKEN_DATA_MARKERS_STEP;
                yCoord = (dataCoordinatesCM.y - TokenManager.CurrentTokenType.DataMarkerOriginPositionCM) / TokenAttributes.TOKEN_DATA_MARKERS_STEP;
            }

            result[0] = (int)Math.Round(xCoord, 0, MidpointRounding.AwayFromZero);
            result[1] = (int)Math.Round(yCoord, 0, MidpointRounding.AwayFromZero);

            return(result);
        }
コード例 #4
0
ファイル: TokenManager.cs プロジェクト: alyssonds/Touchable
 public void SetClassComputeDimensions(bool SetPixels)
 {
     if (SetPixels)
         ClassComputeDimension = ClassComputeDimension.Pixels;
     else
         ClassComputeDimension = ClassComputeDimension.Centimeters;
 }
コード例 #5
0
ファイル: InternalToken.cs プロジェクト: alyssonds/Touchable
        private int[] CalculateDataGridIndexes(Vector2 dataCoordinates, ClassComputeDimension dimension)
        {
            int[] result = new int[2];
            float xCoord;
            float yCoord;

            if(dimension == ClassComputeDimension.Pixels)
            {
                xCoord = (dataCoordinates.x - TokenManager.CurrentTokenType.DataMarkerOriginPositionPX) / TokenManager.CurrentTokenType.DataGridMarkersStepPX;
                yCoord = (dataCoordinates.y - TokenManager.CurrentTokenType.DataMarkerOriginPositionPX) / TokenManager.CurrentTokenType.DataGridMarkersStepPX;
            }
            else
            {
                Vector2 dataCoordinatesCM = new Vector2(ScreenUtils.PixelsToCm(dataCoordinates.x), ScreenUtils.PixelsToCm(dataCoordinates.y));
                xCoord = (dataCoordinatesCM.x - TokenManager.CurrentTokenType.DataMarkerOriginPositionCM) / TokenAttributes.TOKEN_DATA_MARKERS_STEP;
                yCoord = (dataCoordinatesCM.y - TokenManager.CurrentTokenType.DataMarkerOriginPositionCM) / TokenAttributes.TOKEN_DATA_MARKERS_STEP;
            }

            result[0] = (int) Math.Round(xCoord, 0, MidpointRounding.AwayFromZero);
            result[1] = (int)Math.Round(yCoord, 0, MidpointRounding.AwayFromZero);

            return result;

        }
コード例 #6
0
ファイル: InternalToken.cs プロジェクト: alyssonds/Touchable
        public bool ComputeTokenClass(ClassComputeReferenceSystem refSystem, ClassComputeDimension dimension)
        {
            float tokenAngleRad;
            Vector2 dataOriginalPosition;
            Vector2 originPosition;

            if(refSystem == ClassComputeReferenceSystem.Regular)
            {
                tokenAngleRad = this._angle * Mathf.Deg2Rad;
                originPosition = typeMarkers[MarkerType.Origin].Position;
            }
            else
            {
                tokenAngleRad = this.meanSquaredTokenAngle * Mathf.Deg2Rad;
                originPosition = this.meanSquaredTokenReferenceSystem[0].Position;
            }

            dataOriginalPosition = typeMarkers[MarkerType.Data].Position;

            Vector2 dataCoordinates = TokenUtils.ComputeRotoTranslation(dataOriginalPosition, originPosition, tokenAngleRad);

            int[] dataGridIndexes = CalculateDataGridIndexes(dataCoordinates, dimension);

            this._class = TokenManager.CurrentTokenType.GetTokenClass(dataGridIndexes[0], dataGridIndexes[1]);

            if (this._class != null)
                return true;
            else
                return false;
        }
コード例 #7
0
        public void Initialize()
        {
            tokenStatistics = TokenStatistics.Instance;

            switch (TokensEngine.Pars.Type)
            {
                case TokensEngineProperties.TOKEN3x3:
                    CurrentTokenType = (new Token3x3());
                    break;
                case TokensEngineProperties.TOKEN4x4:
                    CurrentTokenType = (new Token4x4());
                    break;
                case TokensEngineProperties.TOKEN5x5:
                    CurrentTokenType = (new Token5x5());
                    break;
            }

            ClusterManager.Instance.Initialize();
            ClusterManager.Instance.SetClusterDistThreshold(CurrentTokenType.TokenDiagonalPX);

            if (TokensEngine.Pars.MeanSquare)
                ClassComputeRefSystem = ClassComputeReferenceSystem.MeanSqure;
            else
                ClassComputeRefSystem = ClassComputeReferenceSystem.Regular;

            ContinuousMeanSquare = TokensEngine.Pars.ContinuousMeanSquare;

            if (TokensEngine.Pars.ComputePixels == TokensEngineProperties.PIXELS)
                ComputeDimension = ClassComputeDimension.Pixels;
            else
                ComputeDimension = ClassComputeDimension.Centimeters;

            TokenUpdateTranslationThreshold = (TokensEngine.Pars.TranslationThr);
            TokenUpdateRotationThreshold = (TokensEngine.Pars.RotationThr);

            // listen to updated cluster events
            ClusterManager.Instance.ClustersUpdateEvent += OnClustersUpdated;
        }