简体   繁体   English

贝塞尔曲线用python拟合数据

[英]Bezier curve fitting to data with python

I know there has been a lot of topics about curve fitting here but I have not found anything that would suite my needs. 我知道这里有很多关于曲线拟合的主题,但是我没有找到任何适合我需求的东西。

I'm trying to make a simple sail analysis app with python. 我正在尝试使用python创建一个简单的帆分析应用程序。 The code "calculates" sail shape stripe and calculates some data from it but I cannot get the correct "entry angle" and "exit angle" as they are defined by the curve control points. 代码“计算”帆形条纹并从中计算出一些数据,但是我无法获得正确的“进入角”和“出口角”,因为它们由曲线控制点定义。

See ref image: 参见参考图片:

So my existing data is in form of x,y points and i would like to fit bezier curve to the existing data so I could calculate the entry and exit angles. 所以我现有的数据是x,y点的形式,我想将bezier曲线拟合到现有数据,以便我可以计算出射角和出射角。 I might also be possible to fit b-spline to the existing data but either way it should be so that the "mid point" and points next to it either side has same y-value. 我也可能使b样条曲线适合现有数据,但是无论哪种方式都应该使“中间点”及其旁边的点的任一侧具有相同的y值。

This question (of fitting Bezier in Python) may have already been answered: 这个问题(在Python中适合Bezier)可能已经被回答:

Bézier curve fitting with SciPy 使用SciPy的贝塞尔曲线拟合

Pomax makes a good point; Pomax很好。 for curve fitting, a simple y=f(x) relation (polynomial, for example) would probably do the job; 对于曲线拟合,可能需要简单的y = f(x)关系(例如多项式); see numpy polyfit, unless there is a specific reason you need a Bezier. 请参见numpy polyfit,除非有特殊原因需要贝塞尔曲线。

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

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