Get the arc length of a 3 or n point bezier curve?

Is it possible to get the length of a bezier curve?

I have made this which will get somewhere close to the length of the bezier curve.

local function getBezierLength(start,...)
    local dist,startTable,startcount = 0,{start,...},select("#",...)
    for k=0.001,1,0.001 do
        local packed = startTable
        for count=startcount,1,-1 do
            local newpack = {}
            for i=1,count do
                newpack[i] = packed[i]:Lerp(packed[i+1],k)
            end
            packed = newpack
        end
        local result = packed[1]
        dist = dist + (start-result).Magnitude
        start = result
    end
    return dist
end

But this is obviously horrible for performance (it literally just gets the distance between 1000 different points along the bezier curve), so it would be better to use an equation to find the length instead of what I’m doing currently.

What I would use this for only uses a 3 point bezier curve, but would it be possible to make it work with n points like the function I made?

1 Like