a = lerp( p0, p1, t );
b = lerp( p1, p2, t );
c = lerp( p2, p3, t );
d = lerp( a, b, t );
e = lerp( a, b, t );
point = lerp( d, e, t );
point =
p0*(-t³+3t²-3t+1)+
p1*(3t³-6t²+3t)+
p2*(-3t³+3t²)+
p3*(t³)
Or, in code:
omt = 1 - t;
omt2 = omt * omt;
t2 = t * t;
point =
p0 * ( omt2 * omt ) +
p1 * ( 3 * omt2 * t ) +
p2 * ( 3 * omt * t2 ) +
p3 * ( t2 * t );
❱ acegikmo.com/bezier/
Correction: e = lerp( b, c, t );
A quirk when using Bézier curves is that the t-value is actually not the same thing as percentage of distance along the curve. The difference in t-value between each segment here is constant, and the animation is linearly animating t, yet the speed is not constant
docs.google.com/presentation/d…
e = lerp( b, c, t );
Let's pretend I did that typo just to make sure you were paying attention 😶
(Also Twitter let us edit tweets already geez)
v = lerp( a, b, t )
is mathematically
v = (1-t)a + bt
a = (1-t)p₀ + tp₁
b = (1-t)p₁ + tp₂
c = (1-t)p₂ + tp₃
d = (1-t)a + tb
e = (1-t)b + tc
point = (1-t)d + te
d = (1-t)((1-t)p₀+tp₁)+t((1-t)p₁+tp₂)
e = (1-t)((1-t)p₁+tp₂)+t((1-t)p₂+tp₃)
point = (1-t)d + te
point = (1-t)((1-t)((1-t)p₀+tp₁)+t((1-t)p₁+tp₂)) + t((1-t)((1-t)p₁+tp₂)+t((1-t)p₂+tp₃))
This is the last we'll see of the lerp-like equations!
point =
-p₀t³ + 3p₀t² - 3p₀t + p₀ +
3p₁t³ - 6p₁t² + 3p₁t -
3p₂t³ + 3p₂t² +
p₃t³
If you look at each line here, you can see that each belong to a specific point
pt =
p₀(-t³+3t²-3t+1) +
p₁(3t³-6t²+3t) +
p₂(-3t³+3t²) +
p₃t³
And thus, we now have our basis functions, which happen to be Bernstein polynomials, for our cubic Bézier curve :)
❱ twitch.tv/acegikmo
medium.com/@Acegikmo/the-…