# Rotate

> Creates a rotation matrix.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## Rotate(Quaternion)

Creates a rotation matrix.

```csharp
public static Matrix4x4 Rotate(Quaternion q)
```

### Parameters

**** (\[Quaternion]\(/engine/6000.7/script-reference/unityengine/quaternion)):&#x20;

### Returns

| Type                                                                  | Description |
| --------------------------------------------------------------------- | ----------- |
| [Matrix4x4](/engine/6000.7/script-reference/unityengine/matrix4x4.md) |             |

### Remarks

```csharp
// Translate, rotate and scale a mesh. Try varying
    // the parameters in the inspector while running
    // to see the effect they have.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Vector3 eulerAngles;
    private MeshFilter mf;
    private Vector3[] origVerts;
    private Vector3[] newVerts;

    void Start() {
        mf = GetComponent<MeshFilter>();
        origVerts = mf.mesh.vertices;
        newVerts = new Vector3[origVerts.Length];
    }

    void Update() {
        Quaternion rotation = Quaternion.Euler(eulerAngles.x, eulerAngles.y, eulerAngles.z);
        Matrix4x4 m = Matrix4x4.Rotate(rotation);
        int i = 0;
        while (i < origVerts.Length) {
            newVerts[i] = m.MultiplyPoint3x4(origVerts[i]);
            i++;
        }
        mf.mesh.vertices = newVerts;
    }
}
```

Additional Resources: [Matrix4x4.TRS](/engine/6000.7/script-reference/unityengine/matrix4x4/trs.md), [Matrix4x4.Scale](/engine/6000.7/script-reference/unityengine/matrix4x4/scale.md), [Matrix4x4.Translate](/engine/6000.7/script-reference/unityengine/matrix4x4/translate.md), [Matrix4x4.SetTRS](/engine/6000.7/script-reference/unityengine/matrix4x4/settrs.md) functions.

## Rotate(Quaternion)

Creates a rotation matrix.

```csharp
public static Matrix4x4 Rotate(in Quaternion q)
```

### Parameters

**** (\[Quaternion]\(/engine/6000.7/script-reference/unityengine/quaternion)):&#x20;

### Returns

| Type                                                                  | Description |
| --------------------------------------------------------------------- | ----------- |
| [Matrix4x4](/engine/6000.7/script-reference/unityengine/matrix4x4.md) |             |

### Remarks

```csharp
// Translate, rotate and scale a mesh. Try varying
    // the parameters in the inspector while running
    // to see the effect they have.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Vector3 eulerAngles;
    private MeshFilter mf;
    private Vector3[] origVerts;
    private Vector3[] newVerts;

    void Start() {
        mf = GetComponent<MeshFilter>();
        origVerts = mf.mesh.vertices;
        newVerts = new Vector3[origVerts.Length];
    }

    void Update() {
        Quaternion rotation = Quaternion.Euler(eulerAngles.x, eulerAngles.y, eulerAngles.z);
        Matrix4x4 m = Matrix4x4.Rotate(rotation);
        int i = 0;
        while (i < origVerts.Length) {
            newVerts[i] = m.MultiplyPoint3x4(origVerts[i]);
            i++;
        }
        mf.mesh.vertices = newVerts;
    }
}
```

Additional Resources: [Matrix4x4.TRS](/engine/6000.7/script-reference/unityengine/matrix4x4/trs.md), [Matrix4x4.Scale](/engine/6000.7/script-reference/unityengine/matrix4x4/scale.md), [Matrix4x4.Translate](/engine/6000.7/script-reference/unityengine/matrix4x4/translate.md), [Matrix4x4.SetTRS](/engine/6000.7/script-reference/unityengine/matrix4x4/settrs.md) functions.
