mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 20:41:49 +00:00
Merge branch 'main' into animation
This commit is contained in:
commit
1186011dcf
23 changed files with 346 additions and 119 deletions
|
|
@ -2,14 +2,36 @@
|
|||
|
||||
Quaternions manipulation library.
|
||||
|
||||
## Quaternion from matrix - *mat4.from_quat(...)*
|
||||
Quaternions can be created as a table of 4 numbers:
|
||||
`{w, x, y, z}`
|
||||
|
||||
## Quaternion from matrix - *quat.from_mat4(...)*
|
||||
|
||||
```lua
|
||||
-- creates a quaternion based on the rotation matrix
|
||||
quat.from_mat4(m: matrix)
|
||||
quat.from_mat4(m: matrix, [optional] dst: quat) -> quat
|
||||
```
|
||||
|
||||
-- writes a quaternion from the rotation matrix to dst
|
||||
quat.from_mat4(m: matrix, dst: quat)
|
||||
## Quaternion of Euler angles - *quat.from_euler(...)*
|
||||
|
||||
```lua
|
||||
-- creates quaternion from euler angles passed as XYZ (pitch, yaw, roll)
|
||||
-- angles in degrees
|
||||
quat.from_euler(euler: vec3, [optional] dst: quat) -> quat
|
||||
```
|
||||
|
||||
## Quaternion composition - quat.mul(...)
|
||||
|
||||
```lua
|
||||
-- multiplies quaternions
|
||||
quat.mul(a: quat, b: quat, [optional] dst: quat) -> quat
|
||||
```
|
||||
|
||||
## 3D vector rotation - quat.mul_vec3(...)
|
||||
|
||||
```lua
|
||||
-- rotates vector by quaternion
|
||||
quat.mul_vec3(a: quat, b: vec3, [optional] dst: vec3) -> vec3
|
||||
```
|
||||
|
||||
## Spherical linear interpolation - *quat.slerp(...)*
|
||||
|
|
@ -19,16 +41,12 @@ The interpolation always take the short path and the rotation is performed at co
|
|||
```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)
|
||||
quat.slerp(a: quat, b: quat, t: number, [optional] dst: quat) -> quat
|
||||
```
|
||||
|
||||
## Casting to string - *quat.tostring(...)*
|
||||
|
||||
```lua
|
||||
-- returns a string representing the contents of the quaternion
|
||||
quat.tostring(q: quat)
|
||||
quat.tostring(q: quat) -> string
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue