Example #1
0
        /// <summary>
        /// Applies a shear to the transform, either before or after this <see cref="AffineMatrix{T}"/>.
        /// </summary>
        /// <param name="shearVector">The vector used to compute the shear.</param>
        /// <param name="order">The order to apply the transform in.</param>
        public virtual void Shear(Vector shearVector, MatrixOperationOrder order)
        {
            Matrix shear = new Matrix(Format, RowCount, ColumnCount, new DoubleComponent(1));

            MatrixProcessor.Shear(shear, shearVector);

            Matrix result;

            if (order == MatrixOperationOrder.Prepend)
            {
                if (Format == MatrixFormat.RowMajor)
                {
                    result = MatrixProcessor.Multiply(shear, this);
                }
                else
                {
                    result = MatrixProcessor.Multiply(this, shear);
                }
            }
            else
            {
                if (Format == MatrixFormat.RowMajor)
                {
                    result = MatrixProcessor.Multiply(this, shear);
                }
                else
                {
                    result = MatrixProcessor.Multiply(shear, this);
                }
            }

            MatrixProcessor.SetMatrix(result, this);
        }
Example #2
0
        /// <summary>
        /// Translates the affine transform by the given translation vector, in the order specified.
        /// </summary>
        /// <param name="translateVector">
        /// A vector whose components will translate the
        /// transform in the corresponding dimension.
        /// </param>
        /// <param name="order">The order to apply the transform in.</param>
        public void Translate(Vector translateVector, MatrixOperationOrder order)
        {
            AffineMatrix translateMatrix = new AffineMatrix(Format, RowCount);

            MatrixProcessor.Translate(translateMatrix, translateVector);

            Matrix result;

            if (Format == MatrixFormat.RowMajor)
            {
                if (order == MatrixOperationOrder.Append)
                {
                    result = MatrixProcessor.Multiply(this, translateMatrix);
                }
                else
                {
                    result = MatrixProcessor.Multiply(translateMatrix, this);
                }
            }
            else
            {
                if (order == MatrixOperationOrder.Append)
                {
                    result = MatrixProcessor.Multiply(translateMatrix, this);
                }
                else
                {
                    result = MatrixProcessor.Multiply(this, translateMatrix);
                }
            }

            MatrixProcessor.SetMatrix(result, this);
        }
Example #3
0
        /// <summary>
        /// Translates the affine transform by the given amount
        /// in each dimension.
        /// </summary>
        /// <param name="amount">Amount to translate by.</param>
        /// <param name="order">The order to apply the transform in.</param>
        public void Translate(DoubleComponent amount, MatrixOperationOrder order)
        {
            Vector translateVector = new Vector(RowCount - 1);

            for (Int32 i = 0; i < translateVector.ComponentCount; i++)
            {
                translateVector[i] = amount;
            }

            AffineMatrix translateMatrix = new AffineMatrix(Format, RowCount);

            MatrixProcessor.Translate(translateMatrix, translateVector);

            Matrix result;

            if (order == MatrixOperationOrder.Append)
            {
                result = MatrixProcessor.Multiply(translateMatrix, this);
            }
            else
            {
                result = MatrixProcessor.Multiply(this, translateMatrix);
            }

            MatrixProcessor.SetMatrix(result, this);
        }
Example #4
0
        /// <summary>
        /// Creates an element-by-element copy of the matrix.
        /// </summary>
        public Matrix Clone()
        {
            Matrix clone = new Matrix(Format, RowCount, ColumnCount);

            MatrixProcessor.SetMatrix(this, clone);

            return(clone);
        }