sorcery  Artifact [4d5bf7109c]

Artifact 4d5bf7109cee46969d2b24f6b38fcf6b762c98aed88e341c2f4307d50e6ee2f5:


local fn = {}

fn.vsep = function(vec) -- separate a vector into a direction + magnitude
	return vec:normalize(), vec:length()
end

fn.vdcomp = function(dist,v1,v2) -- compare the distance between two points
	-- (cheaper than calculating distance outright)
	local d if v2
		then d = vector.subtract(v1,v2)
		else d = v1
	end
	local dsq = (d.x ^ 2) + (d.y ^ 2) + (d.z ^ 2)
	return dsq / (dist^2)
	-- [0,1) == less then
	-- 1 == equal
	-- >1 == greater than
end

return fn