1234567891011121314151617181920212223242526 |
- --extends the math and vector tables.
- --returns the sign of x. Who would have thought?
- math.sign = math.sign or function(x)
- if x < 0 then
- return -1
- elseif x > 0 then
- return 1
- else
- return 0
- end
- end
- if not vector then vector = {} end
- --returns a unit vector pointing the direction from a to b
- vector.aim = function(a, b)
- return vector.normalize(vector.subtract(b, a))
- end
- --returns the inner product of a and b
- vector.dot = function(a, b)
- return a.x * b.x + a.y * b.y + a.z * b.z
- end
|