简体   繁体   English

在javascript中有效地细分贝塞尔曲线

[英]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). 给定起点和终点以及贝塞尔曲线的两个控制点,我想计算细分(在JavaScript中)以近似曲线公差内的直线段(避免段之间的角度太大)。 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/turf-junkyard/turf-bezier - 虽然它不太相同,但我可以使用一些代码,因为我已经有了样条曲线。

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://github.com/seanchas116/bezier-subdivide - 这似乎完全符合我的要求,虽然它看起来像一个递归算法,性能成本很高。

https://pomax.github.io/bezierjs/ - getLUT() could be useful but I would need a way to decide how many steps. https://pomax.github.io/bezierjs/ - getLUT()可能很有用,但我需要一种方法来决定步数。

http://ciechanowski.me/blog/2014/02/18/drawing-bezier-curves/ - pretty much what I want, but this isn't in Javascript. http://ciechanowski.me/blog/2014/02/18/drawing-bezier-curves/ - 几乎是我想要的,但这不是Javascript。

http://antigrain.com/research/adaptive_bezier/ - helpful theory. http://antigrain.com/research/adaptive_bezier/ - 有用的理论。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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