aboutsummaryrefslogtreecommitdiff
path: root/src/json/json.h
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-08-10 22:24:47 +0200
committerest31 <MTest31@outlook.com>2015-08-13 07:56:07 +0200
commita8e238ed06ee8285ed4459e9deda3117419837f6 (patch)
tree9d2d9caee1f9d1a3944d1ba078e7df6e9f13d7c3 /src/json/json.h
parent2b04ab874d75711bc021a0cd8dc7fca68f4e6929 (diff)
downloadminetest-a8e238ed06ee8285ed4459e9deda3117419837f6.tar.gz
minetest-a8e238ed06ee8285ed4459e9deda3117419837f6.tar.bz2
minetest-a8e238ed06ee8285ed4459e9deda3117419837f6.zip
Add count based unload limit for mapblocks
Diffstat (limited to 'src/json/json.h')
0 files changed, 0 insertions, 0 deletions
'n121' href='#n121'>121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146

vector = {}

local function assert_vector(v)
	assert(type(v) == "table" and v.x and v.y and v.z, "Invalid vector")
end

function vector.new(a, b, c)
	if type(a) == "table" then
		assert(a.x and a.y and a.z, "Invalid vector passed to vector.new()")
		return {x=a.x, y=a.y, z=a.z}
	elseif a then
		assert(b and c, "Invalid arguments for vector.new()")
		return {x=a, y=b, z=c}
	end
	return {x=0, y=0, z=0}
end

function vector.equals(a, b)
	assert_vector(a)
	assert_vector(b)
	return a.x == b.x and
	       a.y == b.y and
	       a.z == b.z
end

function vector.length(v)
	assert_vector(v)
	return math.hypot(v.x, math.hypot(v.y, v.z))
end

function vector.normalize(v)
	assert_vector(v)