function CubicSpline.Natural(q)local y=setmetatable({},CubicSpline)y.Points=q y.Coefficients={naturalCubicSpline(q)}local K={}local b=0 for q=1,#q-1,1 do K[q]=integrate(y,q,1)b=b+K[q]end y.Lengths=K y.TotalLength=b return y end function CubicSpline.Clamped(q,y,K)local b=setmetatable({},CubicSpline)b.Points=q b.Coefficients={clampedCubicSpline(q,y,K)}local d={}local c=0 for q=1,#q-1,1 do d[q]=integrate(b,q,1)c=c+d[q]end b.Lengths=d b.TotalLength=c return b end


function CubicSpline.Natural(points)
	local self = setmetatable({}, CubicSpline)
	
	self.Points = points
	self.Coefficients = {naturalCubicSpline(points)}

	local lengths = {}
	local total = 0
	for k = 1, #points - 1 do
		lengths[k] = integrate(self, k, 1)
		total = total + lengths[k]
	end
	
	self.Lengths = lengths
	self.TotalLength = total
	
	return self
end

function CubicSpline.Clamped(points, fpo, fpn)
	local self = setmetatable({}, CubicSpline)
	
	self.Points = points
	self.Coefficients = {clampedCubicSpline(points, fpo, fpn)}

	local lengths = {}
	local total = 0
	for k = 1, #points - 1 do
		lengths[k] = integrate(self, k, 1)
		total = total + lengths[k]
	end
	
	self.Lengths = lengths
	self.TotalLength = total
	
	return self
end
