four.V4

.V4 (x, y, z, w)

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

-- h2. Constructor and accessors

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

@V4(o)@ is a vector converted from the object @o@. Supported types for @o@: @bt.Vector4@.

.x (v)

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

.y (v)

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

.z (v)

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

.z (v)

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

.comp (i, v)

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

.ofV2 (v, z, w)

@ofV2(v, z, w)@ is @V4(V2.x(v), V2.y(v), z, w)@.

.ofV3 (v, w)

@ofV3(v, w)@ is @V4(V3.x(v), V3.y(v), V3.z(v), w)@.

.tuple (v)

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

.tostring (v)

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

.zero ()

@zero()@ is a vector @(0, 0, 0, 0)@.

.ox ()

@ox()@ is a unit vector @(1, 0, 0, 0)@.

.oy ()

@oy()@ is a unit vector @(0, 1, 0, 0)@.

.oz ()

@oz()@ is a unit vector @(0, 0, 1, 0)@.

.ow ()

@ow()@ is a unit vector @(0, 0, 0, 1)@.

.huge ()

@huge()@ is a vector whose components are @math.huge@.

.neg_huge ()

@neg_huge()@ is a vector whose components are @-math.huge@.

.neg (v)

@neg(v)@ is the inverse vector @-v@.

.add (u, v)

@add(u, v)@ is the vector addition @u + v@.

.sub (u, v)

@sub(u, v)@ is the vector subtraction @u - v@.

.mul (u, v)

@mul(u, v)@ is the component wise mutiplication @u * v@.

.div (u, v)

@div(u, v)@ is the component wise division @u / v@.

.smul (s, v)

@smul(s, v)@ is the scalar mutiplication @sv@.

.half (v)

@half(v)@ is the half vector @smul(0.5, v)@.

.dot (u, v)

@dot(u, v)@ is the dot product @u.v@.

.norm (v)

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

.norm2 (v)

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

.unit (v)

@unit(v)@ is the unit vector @v/|v|@.

.homogene (v)

@homogene(v)@ is the vector @v/V4.w(v)@.

.mix (u, v, t)

@mix(u, v, t)@ is the linear interpolation @u + t * (v - u)@.

.trVec (m, v)

@trVec(m, v)@ is the vector @v@ transformed by the @M4@ matrix @m@.

.map (f, v)

@map(f, v)@ is @V3(f(v1), f(v2), f(v3), f(v4))@.

.mapi (f, v)

@mapi(f, v)@ is @V3(f(1, v1), f(2, v2), f(3, v3), f(4, v4))@.

.fold (f, acc, v)

@fold(f, acc, v)@ is @f(f(f(f(acc, v1), v2), v3), v4)@.

.foldi (f, acc, v)

@foldi(f, acc, v)@ is @f(f(f(f(acc, 1, v1), 2, v2), 3, v3), 4, v4)@.

.iter (f, v)

@iter(f, v)@ is @f(v1) f(v2) f(v3) f(v4)@.

.iteri (f, v)

@iteri(f, v)@ is @f(1, v1) f(2, v2) f(3, v3) f(4, v4)@.

.forAll (p, v)

@forAll(p, v)@ is @p(v1) and p(v2) and p(v3) and p(v4)@.

.exists (p, v)

@exists(p, v)@ is @p(v1) or p(v2) or p(v3)@ or p(v4)@.

.eq (u, v, eq)

@eq(u, v [,eq])@ is @true@ if @u@ is equal to @v@ component wise. If [eq] is provided it used as the equality function.

.lt (u, v, lt)

@lt(u, v [,lt])@ is @true@ if @u@ is lower than @v@ component wise. If [lt] is provided it used as the comparison function.

.le (u, v, le)

@le(u, v [,le])@ is @true@ if @u@ is lower or equal than @v@ component wise. If [le] is provided it used as the comparison function.

.compare (u, v, cmp)

@compare(u, v [, cmp])@ is:

  • @-1@ if @u@ is smaller than @v@
  • @0@ if @u@ is equal to @v@
  • @1@ if @u@ is greater than @v@ where the order is the lexicographic order defined by using @cmp@ on the components (@cmp@ defaults to the standard order on floats).

.__unm = lib.neg

h2. Operators

TODO MISSING DOCUMENTATION

.__add = lib.add

TODO MISSING DOCUMENTATION

.__sub = lib.sub

TODO MISSING DOCUMENTATION

.__mul = lib.smul

TODO MISSING DOCUMENTATION

.__tostring = lib.tostring

TODO MISSING DOCUMENTATION

TODO

V4TODO MISSING DOCUMENTATION

V4TODO MISSING DOCUMENTATION

V4TODO MISSING DOCUMENTATION

V4TODO MISSING DOCUMENTATION

V4TODO MISSING DOCUMENTATION