コード例 #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);
        }
コード例 #2
0
ファイル: AffineMatrix.cs プロジェクト: MichealWen/sharpmapv2
        /// <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);
        }
コード例 #3
0
ファイル: AffineMatrix.cs プロジェクト: MichealWen/sharpmapv2
        /// <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);
        }
コード例 #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);
        }
コード例 #5
0
        /// <summary>
        /// Negates the values of a matrix.
        /// </summary>
        /// <param name="value">The matrix to negate.</param>
        /// <returns>A negated matrix instance.</returns>
        public static Matrix operator -(Matrix value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            return(MatrixProcessor.Negate(value));
        }
コード例 #6
0
        /// <summary>
        /// Scalar multiplication.
        /// </summary>
        public static Matrix operator *(Matrix lhs, DoubleComponent rhs)
        {
            if (lhs == null)
            {
                throw new ArgumentNullException("lhs");
            }

            return(MatrixProcessor.ScalarMultiply(lhs, rhs));
        }
コード例 #7
0
 /// <summary>
 /// Applies this transform to the given <paramref name="input"/> vector.
 /// </summary>
 /// <param name="input">Vector to transform.</param>
 public void TransformVector(DoubleComponent[] input)
 {
     if (Format == MatrixFormat.RowMajor)
     {
         MatrixProcessor.Multiply(input, this);
     }
     else
     {
         MatrixProcessor.Multiply(this, input);
     }
 }
コード例 #8
0
 /// <summary>
 /// Applies this transform to the given <paramref name="input"/> vectors.
 /// </summary>
 /// <param name="input">Set of vectors to transform.</param>
 public IEnumerable <Vector> TransformVectors(IEnumerable <Vector> input)
 {
     if (Format == MatrixFormat.RowMajor)
     {
         return(MatrixProcessor.Multiply(input, this));
     }
     else
     {
         return(MatrixProcessor.Multiply(this, input));
     }
 }
コード例 #9
0
        /// <summary>
        /// <see cref="Matrix"/> multiplication.
        /// </summary>
        public static Matrix operator *(Matrix lhs, Matrix rhs)
        {
            if (lhs == null)
            {
                throw new ArgumentNullException("lhs");
            }

            if (rhs == null)
            {
                throw new ArgumentNullException("rhs");
            }

            return(MatrixProcessor.Multiply(lhs, rhs));
        }
コード例 #10
0
        ///// <summary>
        ///// Applies this transform to the given <paramref name="input"/> matrix.
        ///// </summary>
        ///// <param name="input">Matrix to transform.</param>
        ///// <returns>The multiplication of this transform matrix with the input matrix,
        ///// with the transform on the left-hand side of the operation.</returns>
        //public void TransformMatrix(DoubleComponent[][] input)
        //{
        //    MatrixProcessor.Multiply(this, input);
        //}

        /// <summary>
        /// Applies this transform to the given <paramref name="input"/> vector.
        /// </summary>
        /// <param name="input">Vector to transform.</param>
        /// <returns>
        /// The multiplication of this transform matrix with the input vector.
        /// </returns>
        public Vector TransformVector(Vector input)
        {
            DoubleComponent[] elements = new DoubleComponent[input.ComponentCount];
            Array.Copy(input.Components, elements, input.ComponentCount);

            if (Format == MatrixFormat.RowMajor)
            {
                MatrixProcessor.Multiply(elements, this);
            }
            else
            {
                MatrixProcessor.Multiply(this, elements);
            }

            return(new Vector(elements));
        }
コード例 #11
0
ファイル: AffineMatrix.cs プロジェクト: MichealWen/sharpmapv2
 public AffineMatrix Multiply(AffineMatrix b)
 {
     return(new AffineMatrix(MatrixProcessor.Multiply(this, b)));
 }
コード例 #12
0
 /// <summary>
 /// Returns a transpose of the <see cref="Matrix"/>.
 /// </summary>
 /// <value>The rows-for-columns, columns-for-rows transpose of A.</value>
 /// <returns>AT, the transpose of matrix A.</returns>
 public Matrix Transpose()
 {
     return(MatrixProcessor.Transpose(this));
 }
コード例 #13
0
 /// <summary>
 /// Matrix multiplication.
 /// </summary>
 /// <param name="value">Matrix to multiply.</param>
 /// <returns>For matrix A, (value)A.</returns>
 public Matrix Multiply(Matrix value)
 {
     return(MatrixProcessor.Multiply(this, value));
 }
コード例 #14
0
 /// <summary>
 /// Scalar multiplication.
 /// </summary>
 /// <param name="value">Scalar to multiply.</param>
 /// <returns>For matrix A, (value)A.</returns>
 public Matrix Multiply(DoubleComponent value)
 {
     return(MatrixProcessor.ScalarMultiply(this, value));
 }
コード例 #15
0
 /// <summary>
 /// Returns a matrix which is the result of the instance minus the <paramref name="value"/>.
 /// </summary>
 /// <param name="value">The matrix to subtract.</param>
 /// <returns>For matrix A, A - value.</returns>
 public Matrix Subtract(Matrix value)
 {
     return(MatrixProcessor.Subtract(this, value));
 }
コード例 #16
0
 /// <summary>
 /// Returns a matrix which is the result of the instance plus the <paramref name="value"/>.
 /// </summary>
 /// <param name="value">The matrix to add.</param>
 /// <returns>For matrix A, A + value.</returns>
 public Matrix Add(Matrix value)
 {
     return(MatrixProcessor.Add(this, value));
 }
コード例 #17
0
 /// <summary>
 /// Rotates the affine transform around the given <paramref name="axis"/>.
 /// </summary>
 /// <param name="axis">The axis to rotate around.</param>
 /// <param name="radians">Angle to rotate through.</param>
 public virtual void RotateAlong(Vector axis, Double radians)
 {
     MatrixProcessor.Rotate(this, axis, radians);
 }
コード例 #18
0
ファイル: Vector.cs プロジェクト: MichealWen/sharpmapv2
 public Vector Add(Vector b)
 {
     return(MatrixProcessor.Add(this, b));
 }
コード例 #19
0
ファイル: Vector.cs プロジェクト: MichealWen/sharpmapv2
 public Vector Subtract(Vector b)
 {
     return(MatrixProcessor.Subtract(this, b));
 }
コード例 #20
0
 /// <summary>
 /// Returns a copy of the matrix with all the elements negated.
 /// </summary>
 /// <returns>For matrix A, -A.</returns>
 public Matrix Negative()
 {
     return(MatrixProcessor.Negate(this));
 }