four.V2

.V2 (x, y)

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

-- h2. Constructor and accessors

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

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

.x (v)

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

.y (v)

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

.comp (i, v)

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

.ofV3 (v)

@ofV3(v)@ is @V2(V3.x(v), V3.y(v))@.

.ofV4 (v)

@ofV4(v)@ is @V2(V4.x(v), V4.y(v))@.

.tuple (v)

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

.tostring (v)

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

.zero ()

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

.ox ()

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

.oy ()

@oy()@ is a unit vector @(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/V2.y(v)@.

.polarUnit (theta)

@polarUnit(theta)@ is a unit vector whose angular polar coordinate is given by @theta@.

.ortho (v)

@ortho(v)@ is @v@ rotated by @pi/2@.

.mix (u, v, t)

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

.map (f, v)

@map(f, v)@ is @V2(f(v1), f(v2))@.

.mapi (f, v)

@mapi(f, v)@ is @V2(f(1, v1), f(2, v2)@.

.fold (f, acc, v)

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

.foldi (f, acc, v)

@foldi(f, acc, v)@ is @f(f(acc, 1, v1), 2, v2)@.

.iter (f, v)

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

.iteri (f, v)

@iteri(f, v)@ is @f(1, v1) f(2, v2)@.

.forAll (p, v)

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

.exists (p, v)

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

.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

V2TODO MISSING DOCUMENTATION

V2TODO MISSING DOCUMENTATION

V2TODO MISSING DOCUMENTATION

V2TODO MISSING DOCUMENTATION

V2TODO MISSING DOCUMENTATION