sm.vec3.getRotation
Returns a quaternion representing the rotation from one vector to another.
Kind: Function
Environments: Game, Terrain
Game
sm.vec3.getRotation( v1, v2 )
The quaternion can then be multiplied with any vector to rotate it in the same fashion.
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:
Returns:
| Type | Description |
|---|---|
| Quat | The transformation. |
Terrain
sm.vec3.getRotation( v1, v2 )
Open the full Terrain reference
The quaternion can then be multiplied with any vector to rotate it in the same fashion.
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:
Returns:
| Type | Description |
|---|---|
| Quat | The transformation. |