So, i've been trying to learn Bézier curves, but i just don't understand what they are trying to explain. I've copied pasted final code, but that doesn't even work, and gives errors.. So can someone please try to explain what is what it does and how to fix it. Please not too hard, i'm trying to learn it :/
The code i tried
-- bzs is table with bezier urves in it in order traveled
function travelPath(t, bzs)
local totalLength, sums = 0, {}
-- get total length of all curves, also order sums for sorting
for _, bz in next, bzs do
table.insert(sums, totalLength);
totalLength = totalLength + bz.length;
end;
-- get percentage of total distance and find the bezier curve we're on
local T, near, bz = t * totalLength, 0, bzs[1];
for i, n in ipairs(sums) do
if (T - n) < 0 then break; end;
near, bz = n, bzs[i];
end;
-- get relative percentage traveled on given bezier curve
local percent = (T - near)/bz.length;
-- lerp across curve by percentage
local a, b, c = bz:calcFixed(percent);
return a + (b - a) * c;
end;
Please help D:

1 comment
How would i set the points to use? And i'm trying to learn it, i still don't understand it fully :/