1 Star 16 Fork 4

feng3d / bezier

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Bézier曲线

https://wardenfeng.github.io/bezier

创建该库的原始目的是为了解决feng3d引擎粒子中时间与常量的变化曲线问题。

制作Bézier曲线这个库忙了整整3天了,感觉要跳进高等代数的坑了,得赶紧爬出这个坑,这坑太深了,以后再来跳。

说了不陷入,结果又制作了 EquationSolving.ts 提供了方程求解功能。

核心文件

  1. Bezier.ts Bézier曲线
Bezier.ts

解决任意Bézier曲线的求值求导获取极值等问题。

  1. 1次Bézier曲线
    • 求值 bezier.linear
    • 导数 bezier.linearDerivative
    • 二阶导数 bezier.linearSecondDerivative
  2. 2次Bézier曲线
    • 求值 bezier.quadratic
    • 导数 bezier.quadraticDerivative
    • 二阶导数 bezier.quadraticSecondDerivative
  3. 3次Bézier曲线
    • 求值 bezier.cubic
    • 导数 bezier.cubicDerivative
    • 二阶导数 bezier.cubicSecondDerivative
  4. n次Bézier曲线的值 n > 0
    • 求值 bezier.getValue
    • 导数 bezier.getDerivative
    • 二阶导数 bezier.getSecondDerivative
    • N阶导数 bezier.bnND
  5. n次Bézier曲线的极值列表 bezier.getExtremums
  6. n次Bézier曲线的区间列表 bezier.getMonotoneIntervals
  7. 查找区间内极值列表 bezier.getExtremums
  8. 获取目标值所在的插值度T bezier.getTFromValue
  9. 分割曲线,在曲线插值度t位置分割为两条连接起来与原曲线完全重合的曲线 bezier.split
  10. 合并曲线,合并两条连接的曲线为一条曲线并且可以还原为分割前的曲线 bezier.merge
EquationSolving.ts

解决任意一元函数求导以及方程求解等问题。

  1. 获取近似导函数 f'(x) equationSolving.getDerivative
  2. 二分法 求解 f(x) == 0 equationSolving.binary
  3. 连线法 求解 f(x) == 0 equationSolving.line
  4. 切线法 求解 f(x) == 0 equationSolving.tangent
  5. 割线法(弦截法) 求解 f(x) == 0 equationSolving.secant

示例

使用BezierCurve进行模拟canvas提供的 bezierCurveTo方法

quickstart website

随机生成n阶Bézier曲线并且播放插值动画

quickstart website

Bézier曲线编辑器

quickstart website

连续三阶Bézier曲线编辑

quickstart website

基于时间轴的连续三阶Bézier曲线编辑

该示例已经满足feng3d中曲线编辑器的需求。

quickstart website

单元测试

quickstart website

参考资料

  1. https://en.wikipedia.org/wiki/B%C3%A9zier_curve
  2. https://baike.baidu.com/item/%E8%B4%9D%E5%A1%9E%E5%B0%94%E6%9B%B2%E7%BA%BF/1091769
  3. https://blog.csdn.net/venshine/article/details/51750906
  4. https://github.com/venshine/BezierMaker
  5. https://github.com/gre/bezier-easing
  6. https://github.com/vrk/beziertool
  7. https://github.com/gre/bezier-easing-editor
  8. 高等数学 第七版上册 第三章第八节 方程的近似解

关于作者

网站:http://feng3d.com/

github:https://github.com/wardenfeng

github:https://github.com/feng3d-labs

getee:https://gitee.com/feng3d

feng3d交流QQ群:519732759

The MIT License Copyright (c) 2014-2021 feng Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

解决n次Bézier曲线拟合与求解问题 https://feng3d.gitee.io/bezier 展开 收起
TypeScript 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
TypeScript
1
https://gitee.com/feng3d/bezier.git
git@gitee.com:feng3d/bezier.git
feng3d
bezier
bezier
master

搜索帮助