function Bezier.UpdateLength(E)local J=E:GetAllPoints()local Z=E.LengthIterations if#J<2 then return 0,{{0;0,0};{0,0,0}}end local y=0 local p={}for J=1,Z,1 do local K=E:CalculateDerivativeAt((J-1)/(Z-1))y+=K.Magnitude*(1/Z)table.insert(p,{(J-1)/(Z-1);y,K})end E.Length,E.LengthIndeces=y,p end

function Bezier:UpdateLength()
	-- important values
	local points = self:GetAllPoints()
	local iterations = self.LengthIterations

	-- check if points is less than 2 (need at least 2 points to calculate length)
	if #points < 2 then
		return 0, {{0, 0, 0}, {0, 0, 0}}
	end

	-- start iteration
	local l = 0
	local sums = {}
	for i = 1, iterations do
		local dldt = self:CalculateDerivativeAt((i - 1) / (iterations - 1))
		l += dldt.Magnitude * (1 / iterations)
		table.insert(sums, {((i - 1) / (iterations - 1)), l, dldt})
	end

	-- return length and sum table
	self.Length, self.LengthIndeces = l, sums
end

