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.35k stars 289 forks source link

An interval division is incorrect in a sample code for projecting a point #347

Closed emaame closed 2 years ago

emaame commented 2 years ago

I believe at an interval should be divided by 4 (not 5) at refine-binary.js:22, for binary search.

An interval with 5 points: [t1, n1, n2, n3, t2] , then n1 should be t1 + (t2 - t1) / 4.

It is used from a sample code for Projecting a point onto a Bézier curve. Another algorithm is used in Besier.project of besier-js so that this problem does not effect to besier-js (it use a simple linear search).

thank you for your works.

Pomax commented 2 years ago

good catch, thanks for letting me know!

Pomax commented 2 years ago

fixed in https://github.com/Pomax/BezierInfo-2/commit/c683fa699b838d8c2e8e07c7b7d5dacd3fe093e3