lua.wetgenes.tardis.v2
The metatable for a 2d vector class, use the new function to actually create an object.
We also inherit all the functions from tardis.array
lua.wetgenes.tardis.v2.add
v2 = v2:add(v2b)
v2 = v2:add(v2b,r)
Add v2b to v2.
If r is provided then the result is written into r and returned otherwise v2 is modified and returned.
lua.wetgenes.tardis.v2.cross
value = v2:cross(v2b)
Extend to 3d then only return z value as x and y are always 0
lua.wetgenes.tardis.v2.distance
value = a:distance(b)
Returns the length of the vector between a and b.
lua.wetgenes.tardis.v2.dot
value = v2:dot(v2b)
Return the dot product of these two vectors.
lua.wetgenes.tardis.v2.identity
v2 = v2:identity()
Set this v2 to all zeros.
lua.wetgenes.tardis.v2.len
value = v2:len()
Returns the length of this vector.
lua.wetgenes.tardis.v2.lenlen
value = v2: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.v2.mul
v2 = v2:mul(v2b)
v2 = v2:mul(v2b,r)
Multiply v2 by v2b.
If r is provided then the result is written into r and returned otherwise v2 is modified and returned.
lua.wetgenes.tardis.v2.new
v2 = tardis.v2.new()
Create a new v2 and optionally set it to the given values, v2 methods usually return the input v2 for easy function chaining.
lua.wetgenes.tardis.v2.normalize
v2 = v2:normalize()
v2 = v2: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 v2 is modified and returned.
lua.wetgenes.tardis.v2.oo
v2 = v2:oo()
v2 = v2: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 v2 is modified and returned.
lua.wetgenes.tardis.v2.scale
v2 = v2:scale(s)
v2 = v2:scale(s,r)
Scale this v2 by s.
If r is provided then the result is written into r and returned otherwise v2 is modified and returned.
lua.wetgenes.tardis.v2.sub
v2 = v2:sub(v2b)
v2 = v2:sub(v2b,r)
Subtract v2b from v2.
If r is provided then the result is written into r and returned otherwise v2 is modified and returned.