Пример #1
0
 /// <summary>
 /// Combines this affine transfor with the other.
 /// <remarks>
 /// The result of the combined transformation is equivalent to the result
 /// of successive application of transformations. Preferable to use this
 /// form of combination, not ConcatenatedTransform, because
 /// ConcatenatedTransform applies each transformation consistently, and
 /// CombineWith method calculates the resulting transformation matrix.
 /// </remarks>
 /// </summary>
 /// <param name="other">An affine transform to combine</param>
 public void CombineWith(Affine other)
 {
     _matrix = _matrix.Multiply(other._matrix);
     if (_inverseMatrix != null)
     {
         _inverseMatrix = _matrix.GetInverseMatrix();
     }
 }
Пример #2
0
        /// <summary>
        /// Inverts this transform.
        /// </summary>
        /// <remarks>
        /// This method may fail if the transformation matrix
        /// is not invertible.
        /// </remarks>
        public override void Invert()
        {
            if (_inverseMatrix == null)
            {
                _inverseMatrix = _matrix.GetInverseMatrix();
            }

            _isInverse = !_isInverse;
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the MapAround.CoordinateSystem.Transformations.Affine.
        /// </summary>
        private Affine(MathUtils.Matrix matrix, MathUtils.Matrix inverseMatrix, bool isInverse)
        {
            if (inverseMatrix == null)
            {
                throw new ArgumentNullException("inverseMatrix");
            }

            _matrix        = matrix;
            _inverseMatrix = inverseMatrix;
            _isInverse     = isInverse;
        }
Пример #4
0
        /// <summary>
        /// Creates the inverse transform of this object.
        /// </summary>
        /// <remarks>
        /// This method may fail if the transformation matrix
        /// is not invertible.
        /// </remarks>
        public override IMathTransform Inverse()
        {
            if (_inverseMatrix == null)
            {
                _inverseMatrix = _matrix.GetInverseMatrix();

                //values ​​may differ slightly from the exact,
                //in which case check the affinity will not be passed,
                //so set the value of the third column manually
                _inverseMatrix[0, 2] = 0;
                _inverseMatrix[1, 2] = 0;
                _inverseMatrix[2, 2] = 1;
            }

            _inverse = new Affine(_matrix, _inverseMatrix, !_isInverse);

            return(_inverse);
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the MapAround.CoordinateSystem.Transformations.Affine.
        /// </summary>
        private Affine(MathUtils.Matrix matrix, bool isInverse)
        {
            if (matrix == null)
            {
                throw new ArgumentNullException("matrix");
            }

            if (matrix.Size != 3)
            {
                throw new ArgumentException("Affine transform matrix size should be equal three.", "matrix");
            }

            if (matrix[0, 2] != 0 || matrix[1, 2] != 0 || matrix[2, 2] != 1)
            {
                throw new ArgumentException("Matrix does not define an affine transformation.", "matrix");
            }

            _matrix    = matrix;
            _isInverse = isInverse;
        }
Пример #6
0
 /// <summary>
 /// Combines this affine transfor with the other.
 /// <remarks>
 /// The result of the combined transformation is equivalent to the result 
 /// of successive application of transformations. Preferable to use this 
 /// form of combination, not ConcatenatedTransform, because 
 /// ConcatenatedTransform applies each transformation consistently, and 
 /// CombineWith method calculates the resulting transformation matrix.
 /// </remarks>
 /// </summary>
 /// <param name="other">An affine transform to combine</param>
 public void CombineWith(Affine other)
 {
     _matrix = _matrix.Multiply(other._matrix);
     if (_inverseMatrix != null)
         _inverseMatrix = _matrix.GetInverseMatrix();
 }
Пример #7
0
        /// <summary>
        /// Inverts this transform.
        /// </summary>
        /// <remarks>
        /// This method may fail if the transformation matrix 
        /// is not invertible.
        /// </remarks>
        public override void Invert()
        {
            if (_inverseMatrix == null)
                _inverseMatrix = _matrix.GetInverseMatrix();

            _isInverse = !_isInverse;
        }
Пример #8
0
        /// <summary>
        /// Creates the inverse transform of this object.
        /// </summary>
        /// <remarks>
        /// This method may fail if the transformation matrix 
        /// is not invertible.
        /// </remarks>
        public override IMathTransform Inverse()
        {
            if (_inverseMatrix == null)
            {
                _inverseMatrix = _matrix.GetInverseMatrix();

                //values ​​may differ slightly from the exact, 
                //in which case check the affinity will not be passed, 
                //so set the value of the third column manually
                _inverseMatrix[0, 2] = 0;
                _inverseMatrix[1, 2] = 0;
                _inverseMatrix[2, 2] = 1;
            }

            _inverse = new Affine(_matrix, _inverseMatrix, !_isInverse);

            return _inverse;
        }
Пример #9
0
        /// <summary>
        /// Initializes a new instance of the MapAround.CoordinateSystem.Transformations.Affine.
        /// </summary>
        private Affine(MathUtils.Matrix matrix, MathUtils.Matrix inverseMatrix, bool isInverse)
        {
            if (inverseMatrix == null)
                throw new ArgumentNullException("inverseMatrix");

            _matrix = matrix;
            _inverseMatrix = inverseMatrix;
            _isInverse = isInverse;
        }
Пример #10
0
        /// <summary>
        /// Initializes a new instance of the MapAround.CoordinateSystem.Transformations.Affine.
        /// </summary>
        private Affine(MathUtils.Matrix matrix, bool isInverse)
        {
            if (matrix == null)
                throw new ArgumentNullException("matrix");

            if (matrix.Size != 3)
                throw new ArgumentException("Affine transform matrix size should be equal three.", "matrix");

            if (matrix[0, 2] != 0 || matrix[1, 2] != 0 || matrix[2, 2] != 1)
                throw new ArgumentException("Matrix does not define an affine transformation.", "matrix");

            _matrix = matrix;
            _isInverse = isInverse;
        }
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the MapAround.CoordinateSystem.Transformations.Affine.
 /// </summary>
 public Affine(MathUtils.Matrix matrix)
     : this(matrix, false)
 {
 }