算法从点沿着曲线推导出贝塞尔曲线的控制点? [英] Algorithm for deriving control points of a bezier curve from points along that curve?

查看:1748
本文介绍了算法从点沿着曲线推导出贝塞尔曲线的控制点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找,但显然没有找到,一种算法,可以让我在x的列表插件,这被称为是沿曲线y坐标,从而获得4个控制点三次贝塞尔曲线的吐出。

I've been looking for, but obviously not finding, an algorithm that will allow me to plug in a list of x,y coordinates that are known to be along a curve so as to get the 4 control points for a cubic bezier curve spit out.

要更precise,我在寻找一种算法,会给我来塑造曲线必需的,而输入一系列离散的点,包括它决定开始和结束的两个控制点的两个控制点曲线

To be more precise, I'm looking for an algorithm that will give me the two control points required to shape the curve while inputting a series of discrete points including the two control points which determine the start and end of the curve.

谢谢!

编辑:好的,由于数学,一个老对手,我要问的最合适的贝塞尔曲线多项式函数

Okay, due to math, an old foe, I need to ask for the bezier curve of best fit to a polynomial function.

推荐答案

所以我假设端点是固定的,那么你有一些要适应一个三次贝塞尔(X,Y)的采样点。

So I assume that the endpoints are fixed, and then you have a number of (x,y) sample points that you want to fit with a cubic Bezier.

,你必须将决定采取何种方式采样点的数量。让我们来看看通过一些案例:

The number of sample points that you have will determine what approach to take. Let's look through a few cases:

2点

2个样点是最简单的情况。这就给了你一共有4个,如果算上终点。这是CV的在三次贝塞尔的数目。为了解决这个问题,你需要一个参数(T)值两者的采样点。然后你有2个方程和2点,你需要解决,其中的公式是贝塞尔曲线在您所选择的T值的参数方程的系统。

2 sample points is the simplest case. That gives you a total of 4 points, if you count the end points. This is the number of CVs in a cubic Bezier. To solve this, you need a parameter (t) value for both of the sample points. Then you have a system of 2 equations and 2 points that you need to solve, where the equation is the parametric equation of a Bezier curve at the t values you've chosen.

经t值可以是任何你喜欢的,但你会得到更好的结果通过使用1/3和2/3,或在看的相对距离,或沿底线的相对距离,取决于您的数据。

The t values can be whatever you like, but you will get better results by using either 1/3 and 2/3, or looking at relative distances, or relative distances along a baseline, depending on your data.

1分

这是类似于2点,除非你有足够的信息来唯一确定所有的自由度。我的建议是,以适应二次贝塞尔,然后程度的升高。我写了二次装修的具体例子<一href="http://stackoverflow.com/questions/18476308/non-parametric-quadratic-bezier-curve-through-3-points-in-2d-in-r/18485522#18485522">this问题。

This is similar to 2 points, except that you have insufficient information to uniquely determine all your degrees of freedom. What I would suggest is to fit a quadratic Bezier, and then degree elevate. I wrote up a detailed example of quadratic fitting in this question.

以上2点

在这种情况下,没有一个独特的解决方案。我已经使用最小二乘逼近了良好的效果。的步骤是:

In this case, there isn't a unique solution. I have used least-squares approximation with good results. The steps are:

  • 选择牛逼值对每个样品
  • 在构建您的方程组的作为基质
  • 可以选择添加整流罩或其他一些平滑功能
  • 解决矩阵最小二乘法求解器

有这些步骤在此免费CAGD教科书,第11章。它谈论拟合B样条曲线,但三次贝塞尔是一种B样条的(节点矢量是0,0,0,1,1,1,有4个点)。

There is a good description of these steps in this free cagd textbook, chapter 11. It talks about fitting b-splines, but a cubic bezier is a type of b-spline (knot vector is 0,0,0,1,1,1 and has 4 points).

这篇关于算法从点沿着曲线推导出贝塞尔曲线的控制点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆