function CubicSpline.Natural(K)local D=setmetatable({},CubicSpline)D.Points=K D.Coefficients={naturalCubicSpline(K)}local O={}local r=0 for K=1,#K-1,1 do O[K]=integrate(D,K,1)r=r+O[K]end D.Lengths=O D.TotalLength=r return D end function CubicSpline.Clamped(K,D,O)local r=setmetatable({},CubicSpline)r.Points=K r.Coefficients={clampedCubicSpline(K,D,O)}local l={}local V=0 for K=1,#K-1,1 do l[K]=integrate(r,K,1)V=V+l[K]end r.Lengths=l r.TotalLength=V return r end
-- Public Constructors

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
