Pomax / BezierInfo-2

The development repo for the Primer on Bézier curves, https://pomax.github.io/bezierinfo
https://pomax.github.io/bezierinfo
Other
2.29k stars 286 forks source link

Projection identity: why C lies always at the same % from start and end points? #316

Closed luc4leone closed 2 years ago

luc4leone commented 2 years ago

From section 30 "The projection identity":

for any point on the curve with some t value, the ratio of distances from A to B and B to C is fixed: if some t value sets up a C that is 20% away from the start and 80% away from the end, then it doesn't matter where the start, end, or control points are; for that t value, C will always lie at 20% from the start and 80% from the end point.

Pomax, I don't understand why "(A - B) / (B - C) fixed" imply "(C - start point) / (C - end point) fixed".

From the sketch, by moving the points around I see (A - B) / (B - C) is always the same number, but when I move the start or end point, C also moves, and I am not sure C lies always at the same % from start or end point. am I missing something obvious? Thanks :)

Pomax commented 2 years ago

C moves, the physical distances between start point and C, and C and the end point change, but the ratios between those distances do not, and you can verify this by taking a curve you're not sure about, and then just "running the numbers" with a pen an paper (and calculator =D) to confirm that the distance ratio for C stayed exactly the same.

luc4leone commented 2 years ago

yes, doing the same you did in the sketch with the d1/d2 calculation. I was wondering if I was missing some obvious geometrical relationship... but now that you suggest it, I am sure that running the numbers will do it for me. Thanks Pomax

Pomax commented 2 years ago

The geometric relationship you missed is actually a calculus relationship, which is linked to in that section as "Running through the maths" (pointing to https://mathoverflow.net/questions/122257/finding-the-formula-for-bezier-curve-ratios-hull-point-point-baseline), which shows that the ratio function is a pure expression of t, with the derivation showing how the coordinates themselves don't actually matter, which is why the distance ratio can't change: you can move the start and end point as much as you like, but they don't matter. They are not used in the function that tells us where along the (start--end) line we will find C, that is solely determined by the t value we pick.

That's solids maths, but also a bit beyond the scope of the primer itself, so I kept that a link so that folks who want to know more can click through, but you don't need to in order to follow along with how we use the ratio functions for what we're actually trying to achieve, namely: (re)constructing a curve based on a few values.

luc4leone commented 2 years ago

Thanks! 💯