mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-13 15:01:49 +00:00
Merge pull request #936 from Neveix/feat-quat-docs
Add quaternion mul* docs
This commit is contained in:
commit
73541e4ef6
2 changed files with 47 additions and 23 deletions
|
|
@ -2,14 +2,36 @@
|
||||||
|
|
||||||
Quaternions manipulation library.
|
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
|
```lua
|
||||||
-- creates a quaternion based on the rotation matrix
|
-- 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
|
## Quaternion of Euler angles - *quat.from_euler(...)*
|
||||||
quat.from_mat4(m: matrix, dst: quat)
|
|
||||||
|
```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(...)*
|
## Spherical linear interpolation - *quat.slerp(...)*
|
||||||
|
|
@ -19,16 +41,12 @@ The interpolation always take the short path and the rotation is performed at co
|
||||||
```lua
|
```lua
|
||||||
-- creates a quaternion as an interpolation between a and b,
|
-- creates a quaternion as an interpolation between a and b,
|
||||||
-- where t is interpolation factor
|
-- where t is interpolation factor
|
||||||
quat.slerp(a: quat, b: quat, t: number)
|
quat.slerp(a: quat, b: quat, t: number, [optional] dst: quat) -> quat
|
||||||
|
|
||||||
-- 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(...)*
|
## Casting to string - *quat.tostring(...)*
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- returns a string representing the contents of the quaternion
|
-- returns a string representing the contents of the quaternion
|
||||||
quat.tostring(q: quat)
|
quat.tostring(q: quat) -> string
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
Библиотека для работы с кватернионами.
|
Библиотека для работы с кватернионами.
|
||||||
|
|
||||||
|
Кватернионы задаюся таблицей, состоящей из 4 компонентов:
|
||||||
|
`{w, x, y, z}`
|
||||||
|
|
||||||
## Кватернион из матрицы - *quat.from_mat4(...)*
|
## Кватернион из матрицы - *quat.from_mat4(...)*
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- создаёт кватернион на основе матрицы вращения
|
-- создаёт кватернион на основе матрицы вращения
|
||||||
quat.from_mat4(m: matrix) -> quat
|
quat.from_mat4(m: matrix, [опционально] dst: quat) -> quat
|
||||||
|
|
||||||
-- записывает кватернион по матрице вращения в dst
|
|
||||||
quat.from_mat4(m: matrix, dst: quat)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Кватернион из углов Эйлера - *quat.from_euler(...)*
|
## Кватернион из углов Эйлера - *quat.from_euler(...)*
|
||||||
|
|
@ -17,11 +17,21 @@ quat.from_mat4(m: matrix, dst: quat)
|
||||||
```lua
|
```lua
|
||||||
-- создаёт кватернион на основе вектора, содержащего углы Эйлера в порядке XYZ (pitch, yaw, roll)
|
-- создаёт кватернион на основе вектора, содержащего углы Эйлера в порядке XYZ (pitch, yaw, roll)
|
||||||
-- (значения углов строго в градусах)
|
-- (значения углов строго в градусах)
|
||||||
quat.from_euler(euler: vec3) -> quat
|
quat.from_euler(euler: vec3, [опционально] dst: quat) -> quat
|
||||||
|
```
|
||||||
|
|
||||||
-- записывает кватернион в dst на основе вектора, содержащего углы Эйлера в порядке XYZ (pitch, yaw, roll)
|
## Композиция кватернионов - quat.mul(...)
|
||||||
-- (значения углов строго в градусах)
|
|
||||||
quat.from_euler(euler: vec3, dst: quat)
|
```lua
|
||||||
|
-- Умножает два кватерниона (композиция поворотов)
|
||||||
|
quat.mul(a: quat, b: quat, [опционально] dst: quat) -> quat
|
||||||
|
```
|
||||||
|
|
||||||
|
## Поворот 3д вектора на кватернион - quat.mul_vec3(...)
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- Поворачивает вектор на заданный кватернион
|
||||||
|
quat.mul_vec3(a: quat, b: vec3, [опционально] dst: vec3) -> vec3
|
||||||
```
|
```
|
||||||
|
|
||||||
## Сферическая линейная интерполяция - *quat.slerp(...)*
|
## Сферическая линейная интерполяция - *quat.slerp(...)*
|
||||||
|
|
@ -31,11 +41,7 @@ quat.from_euler(euler: vec3, dst: quat)
|
||||||
```lua
|
```lua
|
||||||
-- создаёт кватернион как интерполяцию между a и b,
|
-- создаёт кватернион как интерполяцию между a и b,
|
||||||
-- где t - фактор интерполяции
|
-- где t - фактор интерполяции
|
||||||
quat.slerp(a: quat, b: quat, t: number) -> quat
|
quat.slerp(a: quat, b: quat, t: number, [опционально] dst: quat) -> quat
|
||||||
|
|
||||||
-- записывает кватернион как интерполяцию между a и b в dst,
|
|
||||||
-- где t - фактор интерполяции
|
|
||||||
quat.slerp(a: quat, b: quat, t: number, dst: quat)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Перевод в строку - *quat.tostring(...)*
|
## Перевод в строку - *quat.tostring(...)*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue