# sm.vec3.getRotation

Returns a [quaternion](../Game-Script-Environment/Userdata/Quat.md) representing the rotation from one vector to another.

**Kind:** Function

**Environments:** Game, Terrain

## Game

``` { .lua .api-signature }
sm.vec3.getRotation( v1, v2 )
```

[Open the full Game reference](../Game-Script-Environment/Static-Functions/sm.vec3.md#getrotation)

The quaternion can then be multiplied with any vector to rotate it in the same fashion.

```lua
v1 = sm.vec3.new(1,0,0)
v2 = sm.vec3.new(0,1,0)

trans = sm.vec3.getRotation(v1, v2)
-- `trans` now rotates a vector 90 degrees

print(trans * v2)
-- {<Vec3>, x = -1, y = 0, z = 0}
```

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `v1` | [Vec3](../Game-Script-Environment/Userdata/Vec3.md) | The first vector. |
| `v2` | [Vec3](../Game-Script-Environment/Userdata/Vec3.md) | The second vector. |

**Returns:**

| Type | Description |
| --- | --- |
| [Quat](../Game-Script-Environment/Userdata/Quat.md) | The transformation. |

## Terrain

``` { .lua .api-signature }
sm.vec3.getRotation( v1, v2 )
```

[Open the full Terrain reference](../Terrain-Script-Environment/Static-Functions/sm.vec3.md#getrotation)

The quaternion can then be multiplied with any vector to rotate it in the same fashion.

```lua
v1 = sm.vec3.new(1,0,0)
v2 = sm.vec3.new(0,1,0)

trans = sm.vec3.getRotation(v1, v2)
-- `trans` now rotates a vector 90 degrees

print(trans * v2)
-- {<Vec3>, x = -1, y = 0, z = 0}
```

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `v1` | [Vec3](../Terrain-Script-Environment/Userdata/Vec3.md) | The first vector. |
| `v2` | [Vec3](../Terrain-Script-Environment/Userdata/Vec3.md) | The second vector. |

**Returns:**

| Type | Description |
| --- | --- |
| [Quat](../Terrain-Script-Environment/Userdata/Quat.md) | The transformation. |
