local vec2 = { }

function vec2.new(x, y)
	return { x = x, y = y }
end

function vec2.add(a, b)
	return { x = a.x + b.x, y = a.y + b.y }
end

function vec2.sub(a, b)
	return { x = a.x - b.x, y = a.y - b.y }
end

function vec2.mul(f, v)
	return { x = f * v.x, y = f * v.y }
end

function vec2.length(v)
	return math.sqrt(v.x * v.x + v.y * v.y)
end

function vec2.distance(a, b)
	return vec2.length(vec2.sub(a, b))
end

return vec2
