I deleted my recent topic about this, so I made a new one.
I want to know how I can calculate a bézier other than a cubic and quad, because my zipline system uses it to calculate curves between points
Is there any way to calculate 8 points in a bezier?
I looked wikipedia about a bézier, but I only saw quad and cubic.
I made a module that could calculate it
local Bezier = {}
Bezier.LinearInterpolation = {} -- i created this for no reason
function Bezier.LinearInterpolation.interpolate(a, b, t) -- t stands for time, a is point1, b is point2.
return (1 - t)*a + t*b
end
function Bezier.QuadBezier(a, b, c, t) -- 3 points
return (1 - t)^2*a + 2*(1 - t)*t*b + t^2*c
end
function Bezier.CubicBezier(a, b, c, d, t) -- 4 points
return (1 - t)^3*a + 3*(1 - t)^2*t*b + 3*(1 - t)*t^2*c + t^3*d
end
return Bezier
the rest of my zipline system is made but I need the bezier curve.
you can just keep adding degrees of complexity, the way Bézier curves never changes so if you fundamentally understand 3 points then you can do infinite.
check out this gif. Essentially you have 2 seperate lerps being played, then a third lerp between the position of each of those. All of the lerps go at the same speed relative to distance meaning it creates a nice smooth centered line.
for 4 points you simply start off with 3 lerps on the outer points, then create a 3 point Bézier curve based off those points. For five you would just add another layer of complexity, have 4 lerps between 5 outer points and then do a 4 point lerp based off those. You can do this infinitely.