lua.wetgenes.tardis.v1
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.v1.add
v1 = v1:add(v1b)
v1 = v1:add(v1b,r)
Add v1b to v1.
If r is provided then the result is written into r and returned otherwise v1 is modified and returned.
lua.wetgenes.tardis.v1.cross
value = v1:cross(v1b)
Extend to 3d then only return z value as x and y are always 0
lua.wetgenes.tardis.v1.distance
value = a:distance(b)
Returns the length of the vector between a and b.
lua.wetgenes.tardis.v1.dot
value = v1:dot(v1b)
Return the dot product of these two vectors.
lua.wetgenes.tardis.v1.identity
v1 = v1:identity()
Set this v1 to all zeros.
lua.wetgenes.tardis.v1.len
value = v1:len()
Returns the length of this vector.
lua.wetgenes.tardis.v1.lenlen
value = v1: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.v1.mul
v1 = v1:mul(v1b)
v1 = v1:mul(v1b,r)
Multiply v1 by v1b.
If r is provided then the result is written into r and returned otherwise v1 is modified and returned.
lua.wetgenes.tardis.v1.normalize
v1 = v1:normalize()
v1 = v1: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 v1 is modified and returned.
lua.wetgenes.tardis.v1.oo
v1 = v1:oo()
v1 = v1: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 v1 is modified and returned.
lua.wetgenes.tardis.v1.scale
v1 = v1:scale(s)
v1 = v1:scale(s,r)
Scale this v1 by s.
If r is provided then the result is written into r and returned otherwise v1 is modified and returned.
lua.wetgenes.tardis.v1.sub
v1 = v1:sub(v1b)
v1 = v1:sub(v1b,r)
Subtract v1b from v1.
If r is provided then the result is written into r and returned otherwise v1 is modified and returned.