mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 22:41:49 +00:00
add quat Lua library
This commit is contained in:
parent
b5e7b63a9d
commit
e0cb57a10a
10 changed files with 152 additions and 27 deletions
34
doc/en/scripting/builtins/libquat.md
Normal file
34
doc/en/scripting/builtins/libquat.md
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# *quat* library
|
||||
|
||||
Quaternions manipulation library.
|
||||
|
||||
## Quaternion from matrix - *mat4.from_quat(...)*
|
||||
|
||||
```lua
|
||||
-- creates a quaternion based on the rotation matrix
|
||||
quat.from_mat4(m: matrix)
|
||||
|
||||
-- writes a quaternion from the rotation matrix to dst
|
||||
quat.from_mat4(m: matrix, dst: quat)
|
||||
```
|
||||
|
||||
## Spherical linear interpolation - *quat.slerp(...)*
|
||||
|
||||
The interpolation always take the short path and the rotation is performed at constant speed.
|
||||
|
||||
```lua
|
||||
-- creates a quaternion as an interpolation between a and b,
|
||||
-- where t is interpolation factor
|
||||
quat.slerp(a: quat, b: quat, t: number)
|
||||
|
||||
-- writes a quaternion as an interpolation between a and b to dst,
|
||||
-- where t is interpolation factor
|
||||
quat.slerp(a: quat, b: quat, t: number, dst: quat)
|
||||
```
|
||||
|
||||
## Casting to string - *quat.tostring(...)*
|
||||
|
||||
```lua
|
||||
-- returns a string representing the contents of the quaternion
|
||||
quat.tostring(q: quat)
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue