four.Quat

.Quat (x, y, z, w)

local lib = { type = 'four.Quat' } lib.__index = lib four.Quat = lib setmetatable(lib, { __call = function(lib, ...) return lib.Quat(...) end })

local V3 = four.V3 local V4 = four.V4 local M4 = four.M4

-- h2. Constructor and accessors

--[[-- @Quat(x, y, z, w)@ is a quaternion with the corresponding components.

@Quat(o)@ is a quaternion converted from the object @o@. Supported types for @o@: @bt.Quaternion@.

.x (q)

@x(v)@ is the @x@ component of @v@.

.y (q)

@y(v)@ is the @y@ component of @v@.

.z (q)

@z(v)@ is the @z@ component of @v@.

.z (q)

@w(v)@ is the @w@ component of @v@.

.comp (i, q)

@comp(i, q)@ is the @i@th component of @v@.

.ofV4 (v)

@ofV4(v)@ is a quaternion with @v@'s components.

.toV4 (q)

@toV4(v)@ is a vector with @q@'s components.

.tuple (q)

@tuple(q)@ is @x, y, z, w@, the components of @q@.

.tostring (q)

@tostring(q)@ is a textual representation of @q@.

.ofM4 (m)

@ofM4(m)@ is the unit quaternion for the rotation in the 3x3 top left matrix of @m@.

.toM4 (q)

@toM4(q)@ is the matrix corresponding to the rotation of the unit quaternion @q@.

.quat_eps = 1e-9

h2. Constants

TODO MISSING DOCUMENTATION

.zero ()

@zero()@ is the zero quaternion.

.id ()

@id()@ is the identity quaternion.

.neg (q)

@neg(q)@ is the quaternion @-q@.

.add (q, r)

@add(q, r)@ is the quaternion addition @q + r@.

.sub (q, r)

@sub(q, r)@ is the quaternion subtraction @u - v@.

.mul (q, r)

@mul(q, r)@ is the quaternion multiplication @q * r@

.smul (s, q)

@smul(s, q)@ is the scalar mutiplication @sq@.

.conj (q)

@conj(q)@ is the quaternion conjugate @q*@.

.norm (q)

@norm(q)@ is the norm @|q|@.

.norm2 (q)

@norm2(q)@ is the squared norm @|q|^2@.

.unit (q)

@unit(q)@ is the @unit@ quaternion @q/|q|@.

.inv (q)

@inv(q)@ is the quaternion inverse @q^-1@

.slerp (q, r, t)

@slerp(q, r, t)@ is the spherical spherical linear interpolation between @q@ and @r@ at @t@. Non commutative, torque minimal and constant velocity.

.squad (c, cq, cr, r, t)

@squad(c, cq, cr, r, t)@ is the spherical cubic interpolation between @q@ and @r@ at @t@. @cq@ and @cr@ respectively indicate the tangent orientations at @q@ and @r@.

.nlerp (q, r, t)

@nlerp(q, r, t)@ is the normalized linear interpolation between @q@ and @r@ at @t@. Commutative torque minimal and inconstant velocity.

.rotMap (u, v)

@rotMap(u, v)@ is the unit quaternion for the rotation that maps the unit vector @u@ on the unit vector @v@.

.rotAxis (u, theta)

@rotAxis(u, theta)@ is the unit quaternion for the rotation that rotates 3D space by @theta@ around the unit vector @u@.

.toZYX (q)

@toZYX(q)@ is a vector with the @x@, @y@ and @z@ axis angles of the unit quaternion @q@.

.toAxis (q)

@toAxis(q)@ is @axis, angle@ the rotation axis and angle of the unit quaternion @q@.

.apply3D (q, v)

@apply3D(q, v)@ applies the rotation of the unit quaternion @q@ to the vector @v@.

.apply4D (q, v)

@apply4D(q, v)@ applies the rotation of the unit quaternion @q@ to the vector @v@, the fourth component is left unchanged.

.__unm = lib.neg

h2. Operators

TODO MISSING DOCUMENTATION

.__add = lib.add

TODO MISSING DOCUMENTATION

.__sub = lib.sub

TODO MISSING DOCUMENTATION

.__mul = lib.mul

TODO MISSING DOCUMENTATION

.__tostring = lib.tostring

TODO MISSING DOCUMENTATION

TODO

QuatTODO MISSING DOCUMENTATION

QuatTODO MISSING DOCUMENTATION

QuatTODO MISSING DOCUMENTATION

QuatTODO MISSING DOCUMENTATION

QuatTODO MISSING DOCUMENTATION

QuatTODO MISSING DOCUMENTATION