function Bezier.UpdateLength(F)local T=F:GetAllPoints()local r=F.LengthIterations if#T<2 then return 0,{{0;0;0};{0;0,0}}end local u=0 local V={}for T=1,r,1 do local J=F:CalculateDerivativeAt((T-1)/(r-1))u+=J.Magnitude*(1/r)table.insert(V,{(T-1)/(r-1),u,J})end F.Length,F.LengthIndeces=u,V end
-- updates length of the Bezier
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
