## SIMatrix4.Mul

### Description

Right-multiplies the matrix m1 by the matrix m2 and stores the result into this matrix: this = m1 . m2

### C# Syntax

    SIMatrix4.Mul( SIMatrix4 in_pMatrix1, SIMatrix4 in_pMatrix2 );

### Scripting Syntax

    SIMatrix4.Mul( m1, m2 );

### Parameters

Parameter | Type | Description
--- | --- | ---
m1 | SIMatrix4 | Matrix operand
m2 | SIMatrix4 | Matrix operand

### Examples

#### 1. JScript Example

    /*
            Example of Matrix multiplication
    */
    var m1 = XSIMath.CreateMatrix4( 1.0,  2.0, 3.0, 4.0,
                                           5.0,  6.0, 7.0, 8.0,
                                               9.0, 10.0,11.0,12.0,
                                               13.0,14.0,15.0,16.0 );
    var m2 = XSIMath.CreateMatrix4( 1.0,  0.0, 0.0, 0.0,
                                           0.0,  0.0, 1.0, 0.0,
                                               0.0,  1.0, 0.0, 0.0,
                                               0.0,  0.0, 0.0, 1.0 ) ;
    var m3 = XSIMath.CreateMatrix4();
    var m4 = XSIMath.CreateMatrix4();
    // The m2 matrix will swap 2 and 3rd rows
    // m3 is the composition of m1 and m2
    m3.Mul( m2, m1 ) ;
    Application.LogMessage( "Multipled matrix" ) ;
    PrintMatrix( m3 ) ;
    // m2 is invertible, so we can restore
    // the original matrix
    // (In fact this is not necessary
    // because inversion of m2 = m2)
    m2.InvertInPlace()  ;
    PrintMatrix( m2 ) ;
    m4.Mul( m2, m3 ) ;
    Application.LogMessage( "Restored matrix" ) ;
    PrintMatrix( m4 ) ;
    function PrintMatrix( oMatrix4 )
    {
            for ( var row = 0 ; row < 4 ; row++ )
            {
                    strLine = "" ;
                    for( var col = 0 ; col < 4 ; col++ )
                    {
                            strLine += oMatrix4.Value( row, col ) + "\t\t";
                    }
                    Application.LogMessage( strLine ) ;
            }
    }
    //INFO : Multipled matrix
    //INFO : 1              2               3               4
    //INFO : 9              10              11              12
    //INFO : 5              6               7               8
    //INFO : 13             14              15              16
    //INFO : Restored matrix
    //INFO : 1              2               3               4
    //INFO : 5              6               7               8
    //INFO : 9              10              11              12
    //INFO : 13             14              15              16

#### 2. VBScript Example

    '
    ' This example demonstrates how to multiply two
    ' 4x4 matrices and store the result in a third
    '
    dim m1 : set m1 = XSIMath.CreateMatrix4(_
            1.0, 0.0, 0.0, 0.0, _
            0.0, 2.0, 0.0, 0.0, _
            0.0, 0.0, 3.0, 0.0, _
            0.0, 0.0, 0.0, 1.0)
    dim m2 : set m2 = XSIMath.CreateMatrix4(_
            4.0, 0.0, 0.0, 0.0, _
            0.0, 3.0, 0.0, 0.0, _
            0.0, 0.0, 2.0, 0.0, _
            0.0, 0.0, 0.0, 1.0)
    dim m3 : set m3 = XSIMath.CreateMatrix4
    m3.Mul m1, m2

### See Also

SIMatrix4.MulInPlace SIVector3 SIMatrix3 SIMatrix4 SIRotation SITransformation SIQuaternion