lua.wetgenes.tardis.v4
The metatable for a 4d vector class, use the new function to actually create an object.
We also inherit all the functions from tardis.array
lua.wetgenes.tardis.v4.add
v4 = v4:add(v4b)
v4 = v4:add(v4b,r)
Add v4b to v4.
If r is provided then the result is written into r and returned otherwise v4 is modified and returned.
lua.wetgenes.tardis.v4.distance
value = a:distance(b)
Returns the length of the vector between a and b.
lua.wetgenes.tardis.v4.dot
value = v4:dot(v4b)
Return the dot product of these two vectors.
lua.wetgenes.tardis.v4.identity
v4 = v4:identity()
Set this v4 to all zeros.
lua.wetgenes.tardis.v4.len
value = v4:len()
Returns the length of this vector.
lua.wetgenes.tardis.v4.lenlen
value = v4:lenlen()
Returns the length of this vector, squared, this is often all you need for comparisons so lets us skip the sqrt.
lua.wetgenes.tardis.v4.mul
v4 = v4:mul(v4b)
v4 = v4:mul(v4b,r)
Multiply v4 by v4b.
If r is provided then the result is written into r and returned otherwise v4 is modified and returned.
lua.wetgenes.tardis.v4.new
v4 = tardis.v4.new()
Create a new v4 and optionally set it to the given values, v4 methods usually return the input v4 for easy function chaining.
lua.wetgenes.tardis.v4.normalize
v4 = v4:normalize()
v4 = v4:normalize(r)
Adjust the length of this vector to 1.
An input length of 0 will remain at 0.
If r is provided then the result is written into r and returned otherwise v4 is modified and returned.
lua.wetgenes.tardis.v4.oo
v4 = v4:oo()
v4 = v4:oo(r)
One Over value. Build the reciprocal of all elements.
If r is provided then the result is written into r and returned otherwise v4 is modified and returned.
lua.wetgenes.tardis.v4.scale
v4 = v4:scale(s)
v4 = v4:scale(s,r)
Scale this v4 by s.
If r is provided then the result is written into r and returned otherwise v4 is modified and returned.
lua.wetgenes.tardis.v4.sub
v4 = v4:sub(v4b)
v4 = v4:sub(v4b,r)
Subtract v4b from v4.
If r is provided then the result is written into r and returned otherwise v4 is modified and returned.
lua.wetgenes.tardis.v4.to_v3
v3 = v4:to_v3()
v3 = v4:to_v3(r)
scale [4] to 1 then throw it away so we have a v3 xyz
If r is provided then the result is written into r and returned otherwise a new v3 is created and returned.