简体   繁体   中英

Efficiently subdivide a bezier curve in javascript

Given the start and end points and the two control points of a bezier curve, I would like to calculate the subdivisions (in JavaScript) to approximate the curve with straight line segments within an angular tolerance (avoid too much of an angle between segments). I mainly want to see if there is already an efficient open source algorithm out there before I try to write my own.

Here is what I have found that is close do doing this:

https://github.com/turf-junkyard/turf-bezier - although it's not quite the same, I could use some of the code, since I already have the spline.

https://github.com/seanchas116/bezier-subdivide - this seems to do exactly what I want, although it looks like a recursive algorithm that would be costly to performance.

https://pomax.github.io/bezierjs/ - getLUT() could be useful but I would need a way to decide how many steps.

http://ciechanowski.me/blog/2014/02/18/drawing-bezier-curves/ - pretty much what I want, but this isn't in Javascript.

http://antigrain.com/research/adaptive_bezier/ - helpful theory.

该模块应该做所需的事情: https//github.com/mattdesl/adaptive-bezier-curve

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM