草庐IT

样条曲线(spline)

Vic_Hao 2023-04-12 原文

文章目录

样条(spline)是什么?

  1. 样条是函数,由多项式分段定义。
  2. 样条通常是指分段定义的多项式参数曲线。

样条曲线的定义

样条曲线的分类

常用的样条有许多种,由它们的特征命名。以下列出其中几种:

  • 由表达方式命名:

    • 如果样条是基曲线的线性组合, 则称为B样条(B-spline)
    • 如果每个子区间的多项式由伯恩施坦多项式(Bernstein polynomial)表达,则称为贝塞尔样条(Bézier splines)
  • 由节点的特征命名:

    • 若使用单个节点,每个子区间长度相等且 C n − 1 C^{n-1} Cn1连续,则称为均匀样条(uniform splines)
    • 若对子区间长度没有要求则称为非均匀样条(nonuniform splines)
  • 由特殊条件限制命名:

    • 若要求在a与b二次导数为零则称为自然样条(natural splines)
    • 若要求样条曲线穿过实际数据点则称为插值样条(interpolating splines)

下面详细介绍几种样条:

B-spline

Definition

B 是基(basis)样条的缩略,B-spline是基曲线的线性组合。
B-样条是贝塞尔样条的一种一般化。
当节点数和多项式次数相等时,B-spline退化为Bézier spline。
A B-spline curve is a curve that consists of Bezier curves as segments.

Property

  1. 样条包含在它的控制点的凸包中

B-spline vs. Bézier curve

  1. B-splines are piecewise polynomials. The area of validity for each piece is limited by so called “knot points”. Usually some constraits are put at knot points, for example that we should have a continous curve, maybe also first and second derivatives should be the same there.
  2. While a Bézier curve is defined by a single particular polynomial (a Bernstein polynomial), a spline is defined piecewise by polynomials (meaning you can even have a spline comprising Bézier curves。

How can we prove that a Bezier curve is a specific case of a B-spline curve by the definition of B-splines?

An informal sketch of a proof goes as follows.

A Bezier curve is a parametric curve C(t) = (x(t), y(t)) where x and y are each real-valued polynomials of some degree d. The polynomials x and y are each represented as linear combinations of Bernstein polynomials of degree d, which form a basis for the linear space of all polynomials of degree d.

Now a spline curve is a parametric curve whose x and y components are each piecewise polynomials of degree d. In general, there are n pieces, where n > 1, but we can also have the case where n = 1. In that special case, we have a Bezier curve; the x and y components of the spline curve are each just polynomials, which can be represented as linear combinations of Bernstein polynomials.

Furthermore, it can be proved, using the definition of B-spline (basis) functions of degree d, that if you let the underlying knot sequence be 0,…0, 1…1 — where the knots 0 and 1 each have multiplicity d + 1, then the B-spline basis functions are exactly the Bernstein polynomials.

A note on terminology: frequently spline curves are referred to as B-spline curves, as is done in the wording for this question. But in my answer, I reserve the term B-spline for a basis function, and a spline curve is then a linear combination of B-splines.

Bézier spline

这里注意区分Bézier spline和Bézier curve:Bézier curves can be combined to form a Bézier spline, or generalized to higher dimensions to form Bézier surfaces.

样条插值

样条插值就是分段低次多项式、在分段处具有一定光滑性的函数插值,它克服了高次多项式插值可能出现的振荡现象,具有较好的数值稳定性和收敛性,由这种插值过程产生的函数就是多项式样条函数。

有关样条曲线(spline)的更多相关文章

  1. Ruby 曲线拟合(对数回归)包 - 2

    我正在寻找进行对数回归(对数方程的曲线拟合)的Rubygem或库。我试过statsample(http://ruby-statsample.rubyforge.org/),但它似乎没有我要找的东西。有人有什么建议吗? 最佳答案 尝试使用“statsample”gem。您可以使用类似的方法执行指数、对数、幂、正弦或任何其他变换。我希望这有帮助。require'statsample'#IndependentVariablex_data=[Math.exp(1),Math.exp(2),Math.exp(3),Math.exp(4),Ma

  2. Ruby/openssl:将椭圆曲线点八位字节字符串转换为 OpenSSL::PKey::EC::Point - 2

    我正在尝试编写Ruby代码来检查我发现的特定消息上的椭圆曲线数字签名算法(ECDSA)签名here.问题是我不知道如何将公钥的八位字节字符串转换为OpenSSL::PKey::EC::Point目的。如果我用C写这个,我会把八位字节字符串传递给OpenSSL的o2i_ECPublicKey,它做的事情接近我想要的,实际上被referenceimplementation使用.但是,我搜索了sourcecodeofRuby(MRI)而且它不包含对o2i_ECPublicKey的调用,所以我不知道如何在不编写C扩展的情况下使用Ruby中的该函数。这是十六进制的八位字节字符串。它只是一个0x0

  3. javascript - 如何检测由贝塞尔曲线制成的物体与圆之间的碰撞? - 2

    所以我写了一个微生物动画。这一切都很酷,但我认为,如果微生物能够吃掉硅藻并破坏气泡,那就更好了。问题在于微生物是由贝塞尔曲线构成的。我不知道如何以合理的方式检查由贝塞尔曲线构成的对象与圆之间的碰撞。我唯一想到的是在隐藏的Canvas上绘制微生物形状和气泡,然后检查它们是否绘制到相同的像素。但这会导致严重的性能问题恕我直言。代码:https://codepen.io/michaelKurowski/pen/opWeKYclassCell是单元格,而classCellWallNode是贝塞尔曲线的节点,以防有人需要查看实现。气泡和硅藻可以很容易地简化为圆形。 最

  4. javascript - 什么样的算法可以生成这样的曲线 (img) & 它可以在 javascript 中为 flot 完成吗? - 2

    你能给我一个算法的例子吗?alttexthttp://ryancalderoni.com/archive/ideal_curve.jpg编辑:然后我将如何使用Javascript计算数学?有人可以添加吗?很抱歉最初没有包含该上下文..注意:我正在使用“flot”来绘制它,flot的输入是一个javascript数组,如下所示:[[x,y],[x,y],[x,y]...]因此,给定改变曲线的值,我将所有点输出到一个带有循环的数组,然后将其吐出以float到图形中。 最佳答案 典型的S型曲线是tanh(x)曲线。根据定义,tanh(x)

  5. javascript - 在 threejs 中沿路径或样条线移动对象 - 2

    我试图在Three.js中沿着路径移动对象。我想以“构造”的方式构建路径,使用Path对象,如下所示:varpath=newTHREE.Path([newTHREE.Vector2(0,0),newTHREE.Vector2(0,inDistance)]);path.arc(arcRadius,0,arcRadius,Geo.rad(180),Geo.rad(90),true);path.lineTo(arcRadius+outDistance,arcRadius+inDistance);然后我可以使用path.getPoint(t)和path.getTangent(t)为我的对象获取

  6. javascript - 通过一组 N 个点绘制一条曲线,其中 N>2 - 2

    我需要使用Javascript通过N>2的N个点平滑地绘制一条曲线。我目前在html5Canvas对象中使用bezierCurveTo()。我投入了大量时间来寻找实现此目的的最佳方法,虽然Catmull-RomSplines听起来很有前途,但我不知道有什么方法可以将它们绘制成线条。因此,我只剩下Poly-lineBézier曲线,需要找到所有中间控制点。我花了很多时间重新学习数学,但我有一个部分可用的例子here。这条线有时不是特别平滑,而且我的控制点对于某些矢量是关闭的问题。Here是我最初的math.stackexchange问题,我要求它获得控制点的大部分数学。我也愿意使用Cat

  7. 固定长度的 Javascript Canvas 曲线 - 2

    我想绘制任意(随机)曲线,给定:起点终点曲线长度受Canvas边界限制,加上曲线不能交叉,我怎么能做这样的事情。我试图找到一些解决方案,但我无法弄清楚。感谢您的宝贵时间。这是我想要完成的更详细的View:这是画在Canvas上的二次曲线。一切都好。问题是,如何在没有所有点的情况下绘制它,仅使用以像素为单位的固定长度、随机点、受Canvas大小限制且不交叉。代码可能是这样的:functionfixedCurve(A,B,length){for(inti=A;i 最佳答案 试试这个(fiddle):functiondraw(){varc

  8. javascript - 当用户滚动时沿着曲线路径移动元素 - 2

    我正在尝试创建一个页面,在该页面中,当用户滚动时,火箭会沿着预定路径蜿蜒向上(页面将在底部加载)。我可以使用类似jQuery.path的方式为路径上的元素设置动画并使用SVG的animateMotion,但我无法完全找出一个解决方案,让元素在用户滚动时沿着该路径移动。jQuery滚动路径并不是我想要的,因为它将元素移动到页面的中心。我在TEDxGUC上看到过网站,当您向下滚动时,他们会沿着弯曲的路径移动苹果。我可以看到他们正在使用Raphael.js和“沿路径的动画”扩展,但我仍然无法理解他们实际上是如何实现它的——我还不是一个JS忍者。非常感谢任何指向正确方向的指示!编辑对于仍然对这

  9. javascript - 让用户在谷歌地图上画曲线? - 2

    有没有人有任何例子或来源让用户绘制从a点到b点的曲线图?谢谢,亚历克斯 最佳答案 您可以这样绘制贝塞尔曲线:varGmapsCubicBezier=function(lat1,long1,lat2,long2,lat3,long3,lat4,long4,resolution,map){varpoints=[];for(it=0;it您可以修改代码,以提供不同的策略来绘制线条。实现的是用“阴影”指向的。用法很简单:varcurvedLine=newGmapsCubicBezier(initLat,initLong,control1La

  10. javascript - 重新创建 CSS3 过渡 Cubic-Bezier 曲线 - 2

    在CSS3过渡中,您可以将计时函数指定为'cubic-bezier:(0.25,0.3,0.8,1.0)'在该字符串中,您只需为曲线上的点P1和P2指定XY,因为P0和P3始终分别为(0.0,0.0)和(1.0,1.0)。根据Apple的网站:x[is]表示为总持续时间的分数,y表示为总变化的分数我的问题是如何将其映射回javascript中的传统一维T值?--FromAppledocsonanimatingwithtransitions 最佳答案 稍微浏览一下webkit-source,以下代码将为CSS3过渡中使用的隐式曲线提供

随机推荐