[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/vr/ - Retro Games

Search:


View post   

>> No.2632049 [View]
File: 35 KB, 540x389, 540px-Pascal_s_triangle_5_svg_copy_detail_em[1].jpg [View same] [iqdb] [saucenao] [google]
2632049

>>2632007
>bezier curves may sound complex
https://en.wikipedia.org/wiki/B%C3%A9zier_curve
Also what I mean by this is when the article shows the not yet simplified formula it can look daunting, and there are plenty of sites that have articles that explain them in math jargon, but they're pretty fucking simple.
pic related is a pascal's triangle, one of these is all you need to construct an nth degree bezier curve
so you have point_1 and point_2, and t
t is clamped between 0 and 1.0
so for instance a 2nd degree or linear bezier curve [a straight line] is
[1 - t]*[point_1] + t*[point_2]
which is just taking the difference between the two values and adding them to the thing as t progresses from 0 to 1
like at 0 you can see that point_1 is times 1, and point_2 is not affecting it because it's being multiplied by 0
NOW
with added degrees all you're doing is adding in another control point, which is a point that the curve will approach but not reach
for an nth level curve you don't even need to do simplification of the formulas, you can just follow this trick
arrange your points from least to greatest aka
p0, p1, p2, p3
for 4 points, then
from p0 to p3, add in t^x where x is from 0 increasing by 1 until you're at the end
so
t^0, t^1, t^2, t^3, note that t^0 = 1
then do [1 - t]^x in reverse, so
[1 - t]^3, [1 - t]^2, [1 - t]^1, [1 - t]^0
and then for the coefficients you pull from the row of pascal's triangle that has the same number of numbers as your polynomial, so for this from row 3, getting
1, 3, 3, 1
each term is multiplied by the terms in the same position in the list, so for each listed is say A, B, C, D, you'd multiply all the A's with the A's, B's with the B's, etc, with all added together
so in the end, working from above it's

p0, p1, p2, p3
t^0, t^1, t^2, t^3
[1 - t]^3, [1 - t]^2, [1 - t]^1, [1 - t]^0
1, 3, 3, 1

so

( [1 - t]^3*[p0] ) + ( t^1*[1 - t]^2*[p1]*3 ) + ( t^2*[1 - t]^1*[p2]*3 ) +( t^3*[p3] )

Navigation
View posts[+24][+48][+96]