Пример #1
0
        /// <summary>
        /// Initialises a new instance of the <see cref="Matrix4x4"/> struct.
        /// </summary>
        /// <param name="sourceMatrix">The source matrix.</param>
        /// <param name="valueGenerator">
        /// The <see cref="MatrixValueGeneratorDelegate"/> to use to generate new matrix values. Can use the source matrix
        /// or can ignore it.
        /// </param>
        public Matrix4x4(double[][] sourceMatrix, MatrixValueGeneratorDelegate valueGenerator)
        {
            // construct the columns
            matrix = new double[4][];

            try
            {
                // for each column in the target matrix
                for (int i = 0; i < 4; i++)
                {
                    // construct the rows
                    matrix[i] = new double[4];

                    // for each row in the target matrix
                    for (int j = 0; j < 4; j++)
                    {
                        // set the value at [i, j] according to the given generator function
                        this[i, j] = valueGenerator(sourceMatrix, i, j);
                    }
                }
            }
            catch (IndexOutOfRangeException ex)
            {
                throw new ArgumentException("Source array is not a minimum of 4x4 in size.", nameof(sourceMatrix), ex);
            }
        }
Пример #2
0
 /// <summary>
 /// Initialises a new instance of the <see cref="Matrix4x4"/> struct.
 /// </summary>
 /// <param name="sourceMatrix">The source matrix.</param>
 /// <param name="valueGenerator">
 /// The <see cref="MatrixValueGeneratorDelegate"/> to use to generate new matrix values. Can use the source matrix
 /// or can ignore it.
 /// </param>
 public Matrix4x4(Matrix4x4 sourceMatrix, MatrixValueGeneratorDelegate valueGenerator) :
     this((double[][])sourceMatrix, valueGenerator)
 {
 }