add quaternion mul* docs

This commit is contained in:
neveix 2026-08-15 14:01:46 +05:00
parent 585b8247d5
commit 22b70b701e
2 changed files with 59 additions and 1 deletions

View file

@ -2,7 +2,10 @@
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
@ -12,6 +15,38 @@ quat.from_mat4(m: matrix)
quat.from_mat4(m: matrix, dst: quat) 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) -> quat
-- writes quaternion from euler angles passed as XYZ (pitch, yaw, roll) to dst
-- angles in degrees
quat.from_euler(euler: vec3, dst: quat)
```
## Quaternion composition - quat.mul(...)
```lua
-- multiplies quaternions
quat.mul(a: quat, b: quat) -> quat
-- writes a quaternions multiplication result to dst
quat.mul(a: quat, b: quat, dst: quat)
```
## 3D vector rotation - quat.mul_vec3(...)
```lua
-- rotates vector by quaternion
quat.mul_vec3(a: quat, b: vec3) -> vec3
-- writes rotated vector by quaternion to dst
quat.mul_vec3(a: quat, b: vec3, dst: vec3)
```
## Spherical linear interpolation - *quat.slerp(...)* ## Spherical linear interpolation - *quat.slerp(...)*
The interpolation always take the short path and the rotation is performed at constant speed. The interpolation always take the short path and the rotation is performed at constant speed.

View file

@ -2,6 +2,9 @@
Библиотека для работы с кватернионами. Библиотека для работы с кватернионами.
Кватернионы задаюся таблицей, состоящей из 4 компонентов:
`{w, x, y, z}`
## Кватернион из матрицы - *quat.from_mat4(...)* ## Кватернион из матрицы - *quat.from_mat4(...)*
```lua ```lua
@ -24,6 +27,26 @@ quat.from_euler(euler: vec3) -> quat
quat.from_euler(euler: vec3, dst: quat) quat.from_euler(euler: vec3, dst: quat)
``` ```
## Композиция кватернионов - quat.mul(...)
```lua
-- Умножает два кватерниона (композиция поворотов)
quat.mul(a: quat, b: quat) -> quat
-- Записывает кватернион как произведение двух кватернионов (композиция поворотов)
quat.mul(a: quat, b: quat, dst: quat)
```
## Поворот 3д вектора на кватернион - quat.mul_vec3(...)
```lua
-- Поворачивает вектор на заданный кватернион
quat.mul_vec3(a: quat, b: vec3) -> vec3
-- Записывает результат поворота вектора на заданный кватернион
quat.mul_vec3(a: quat, b: vec3, dst: vec3)
```
## Сферическая линейная интерполяция - *quat.slerp(...)* ## Сферическая линейная интерполяция - *quat.slerp(...)*
Интерполяция всегда выполняется по короткому пути, а вращение выполняется с постоянной скоростью. Интерполяция всегда выполняется по короткому пути, а вращение выполняется с постоянной скоростью.