lua.wetgenes.tardis.v3
The metatable for a 3d vector class, use the new function to actually create an object.
We also inherit all the functions from tardis.array
lua.wetgenes.tardis.v3.add
v3 = v3:add(v3b)
v3 = v3:add(v3b,r)
Add v3b to v3.
If r is provided then the result is written into r and returned otherwise v3 is modified and returned.
lua.wetgenes.tardis.v3.angle
radians,axis = v3a:angle(v3b)
radians,axis = v3a:angle(v3b,axis)
Return radians and axis of rotation between these two vectors. If axis is given then it must represent a positive world aligned axis normal. So V3(1,0,0) or V3(0,1,0) or V3(0,0,1) only. The point of providing an axis allows the returned angle to be over a 360 degree range rather than flipping the axis after 180 degrees this means the second axis returned value can be ignored as it will always be the axis that is passed in.
lua.wetgenes.tardis.v3.cross
v3 = v3:cross(v3b)
v3 = v3:cross(v3b,r)
Return the cross product of these two vectors.
If r is provided then the result is written into r and returned otherwise v3 is modified and returned.
lua.wetgenes.tardis.v3.distance
value = a:distance(b)
Returns the length of the vector between a and b.
lua.wetgenes.tardis.v3.dot
value = v3:dot(v3b)
Return the dot product of these two vectors.
lua.wetgenes.tardis.v3.identity
v3 = v3:identity()
Set this v3 to all zeros.
lua.wetgenes.tardis.v3.len
value = v3:len()
Returns the length of this vector.
lua.wetgenes.tardis.v3.lenlen
value = v3: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.v3.mul
v3 = v3:mul(v3b)
v3 = v3:mul(v3b,r)
Multiply v3 by v3b.
If r is provided then the result is written into r and returned otherwise v3 is modified and returned.
lua.wetgenes.tardis.v3.new
v3 = tardis.v3.new()
Create a new v3 and optionally set it to the given values, v3 methods usually return the input v3 for easy function chaining.
lua.wetgenes.tardis.v3.normalize
v3 = v3:normalize()
v3 = v3: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 v3 is modified and returned.
lua.wetgenes.tardis.v3.oo
v3 = v3:oo()
v3 = v3: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 v3 is modified and returned.
lua.wetgenes.tardis.v3.scale
v3 = v3:scale(s)
v3 = v3:scale(s,r)
Scale this v3 by s.
If r is provided then the result is written into r and returned otherwise v3 is modified and returned.
lua.wetgenes.tardis.v3.sub
v3 = v3:sub(v3b)
v3 = v3:sub(v3b,r)
Subtract v3b from v3.
If r is provided then the result is written into r and returned otherwise v3 is modified and returned.