Quaternion
Quaternions are a set of complex numbers that can be used to represent spatial rotation. In Quoll, all properties and methods that require rotation, use quaternions. All quaternions must be in normalized form. Failing to do so will provide unexpected results.
Properties
x: number
X component (imaginary) of Quaternion.
local q = Quaternion.new(0.350225, 0.078362, 0.416451, 0.835327)
local x = q.x -- 0.350225
### `y: number` \{#prop-y}
Y component (imaginary) of Quaternion.
```lua
local q = Quaternion.new(0.350225, 0.078362, 0.416451, 0.835327)
local y = q.y -- 0.078362
z: number
Z component (imaginary) of Quaternion.
local q = Quaternion.new(0.350225, 0.078362, 0.416451, 0.835327)
local z = q.z -- 0.416451
w: number
W component (real) of Quaternion.
local q = Quaternion.new(0.350225, 0.078362, 0.416451, 0.835327)
local w = v.w -- 0.835327
Methods
new(x: number, y: number, z: number, w: number): Quaternion
Creates new Quaternion with provided values.
local q = Quaternion.new(0.350225, 0.078362, 0.416451, 0.835327)
Properties:
x
: X imaginary componenty
: Y imaginary componentz
: Z imaginary componentw
: W real component
Returns:
Quaternion based on provided values
fromEulerAngles(x: number, y: number, z: number): Quaternion
Creates new Quaternion from euler angles in XYZ order.
local q = Quaternion.fromEulerAngles(0.6108652, 0.4363323, 0.7853982)
Properties:
x
: X euler angle in radiansy
: Y euler angle in radiansz
: Z euler angle in radians
Returns:
Quaternion calculated from euler angles.
toEulerAngles(q: Quaternion): Vector3
Returns euler angles in XYZ order as Vector3.
local q = Quaternion.new(0.350225, 0.078362, 0.416451, 0.835327)
local v = Quaternion.toEulerAngles(q)
Properties:
q
: Quaternion
Returns:
Euler angles in radians as Vector3 calculated in XYZ order from Quaternion