local function q(q,r)if SETTINGS.Debug==true then for q,r in r do newInstance("\080\097\114\116",{Position=r,Anchored=true,CanCollide=false,Size=Vector3.one,Color=Color3.fromRGB(0,255,0),Transparency=.5;Parent=workspace.Debris})end end while#r>1 do local w=r r={}for B=1,#w-1,1 do local E=w[B]local v=w[B+1]table.insert(r,lerp(E,v,q))end end if SETTINGS.Debug==true then newInstance("\080\097\114\116",{Position=r[1];Anchored=true;CanCollide=false;Size=Vector3.one,Color=Color3.fromRGB(255,0,0),Transparency=.5;Parent=workspace.Debris})end return r[1]end return q
-- O(n!)
local function createCurve(t, points)
	if SETTINGS.Debug == true then
		for _, point in points do
			newInstance("Part", {
				Position = point,
				Anchored = true,
				CanCollide = false,
				Size = Vector3.one,
				Color = Color3.fromRGB(0, 255, 0),
				Transparency = 0.5,
				Parent = workspace.Debris,
			})
		end
	end

	-- could use recursion, but lua doesn't have optimized tail calls.
	while #points > 1 do
		local tempPoints = points
		points = {}

		for i = 1, #tempPoints - 1 do
			local p1 = tempPoints[i]
			local p2 = tempPoints[i + 1]

			table.insert(points, lerp(p1, p2, t))
		end
	end

	if SETTINGS.Debug == true then
		newInstance("Part", {
			Position = points[1],
			Anchored = true,
			CanCollide = false,
			Size = Vector3.one,
			Color = Color3.fromRGB(255, 0, 0),
			Transparency = 0.5,
			Parent = workspace.Debris,
		})
	end

	-- points[1] will contain the correct position at time 't'
	return points[1]
end

return createCurve
