## SIMatrix3.GetQuaternion

### Introduced

v3.5

### Description

Returns the rotation quaternion representation of this matrix3.

### C# Syntax

    SIMatrix3.GetQuaternion( SIQuaternion out_pVal );

### Scripting Syntax

    SIMatrix3.GetQuaternion( q );

### Parameters

Parameter | Type | Description
--- | --- | ---
q | SIQuaternion | The rotation quaternion containing the new matrix3 values.

### Examples

#### JScript Example

    /*
            This example illustrates how to get the orientation of
            one object relative to another.
    */
    // CREATE OBJECTS A & B
    var A = ActiveSceneRoot.AddNull("A");
    var B = ActiveSceneRoot.AddNull("B");
    // GET GLOBAL TRANSFORM OF A & B
    var gksA = A.Kinematics.Global;
    var gksB = B.Kinematics.Global;
    var tgA = gksA.Transform;
    var tgB = gksB.Transform;
    // TRANSLATE & ROTATE A
    var vA = XSIMath.CreateVector3(2, 2, 0);
    tgA.SetTranslation(vA);
    var rA = XSIMath.CreateRotation( 0, 0, XSIMath.DegreesToRadians(45) );
    tgA.SetRotation(rA);
    gksA.Transform = tgA;
    // GET LOCAL TRANSFORM OF B RELATIVE TO A
    var mA = XSIMath.CreateMatrix3();
    var mB = XSIMath.CreateMatrix3();
    tgA.GetRotationMatrix3(mA);
    tgB.GetRotationMatrix3(mB);
    mA.TransposeInPlace();
    mB.MulInPlace(mA);
    // GET ORIENTATION OF B RELATIVE TO A AS A QUATERNION
    var qB = XSIMath.CreateQuaternion();
    mB.GetQuaternion(qB);
    // LOG RESULT
    Application.LogMessage("Q(" + qB.w + "," + qB.x + "," + qB.y + "," + qB.z);
    // Verify result by creating a child on A and transform it to
    // have the same orientation as B
    var oChild = A.AddNull("Child");
    var lksChild = oChild.Kinematics.Local;
    var tlChild = XSIMath.CreateTransform();
    tlChild.SetRotationFromQuaternion(qB);
    lksChild.Transform = tlChild;
    // Expected results:
    // INFO : Q(0.9238795325112867,0,0,-0.3826834323650898

### See Also

SIMatrix3.SetFromQuaternion