立方体样条:开始/结束段插值 [英] Cubic Spline : Start/End Segment interpolation

查看:220
本文介绍了立方体样条:开始/结束段插值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C ++中执行样条插值。我使用了这里的代码: http:/ /tehc0dez.blogspot.ch/2010/04/nice-curves-catmullrom-spline-in-c.html (代码也链接在该页面上,它在github上)。该应用程序是工作正好很好的封闭轮廓,因为它复制的前三个点到结束。

I'm doing Spline interpolation in C++. I've used code from here: http://tehc0dez.blogspot.ch/2010/04/nice-curves-catmullrom-spline-in-c.html (the code is also linked on that page, it's up on github). The app is working just fine for closed contours, since it's copying the first three points to the end.

但是在我的例子中,我需要能够创建一个开放的形状 - 或者线条 - ,其中第一点和最后一点没有连接。

But in my case I need to be able to make an "open" shape - or rather line-, where the first and last points are not connected.

我的理解是,由于Catmull-Rom样条是三次的,我将无法计算第一个和最后一个段的内插点,点。

It is my understanding that since the Catmull-Rom spline is cubic, I won't be able to calculate the interpolated points for the first and last segment without adding any additional points.

我读到一个常见的方法来插入这两个段中的点是使用二次插值。

I read that a common method to interpolate the points in those two segments is to use Quadratic Interpolation.

不幸的是,我无法围绕如何做到这一点。我已经找到了如何做二次贝塞尔近似,但这不是我想做的,因为我不想引入任何额外的支持点。

Unfortunately I can't wrap my head around how to do this. I've found out how to do quadratic Bezier approximation, but this is not what I want to do since I don't want to introduce any additional support points.

我找到此网站: http:// dafeda。其中很好地解释了如何进行二次插值。但我不知道如何适应我的情况,在那里我想计算一个新的点,而不只是y。

I found this site: http://dafeda.wordpress.com/2010/09/01/newtons-divided-difference-polynomial-quadratic-interpolation/ Which explains quite nicely how to do Quadratic interpolation. But I don't know how to adapt this for my case, where I want to calculate a new Point rather than just y.

任何帮助将不胜感激。感谢!

Any help would be appreciated. Thanks !

推荐答案

由于这里提供的公式,管理实现一个体面的解决方案: http://www.doc.ic.ac.uk/~dfg/AndysSplineTutorial/Parametrics.html

Managed to implement a decent solution thanks to the formula found here: http://www.doc.ic.ac.uk/~dfg/AndysSplineTutorial/Parametrics.html

他们还提供了一个不错的Java小程序来检查不同的参数。

They also provide a nice Java applet to check out the different parameters.

t1值到0.5,并检查t是否高于/低于这个阈值,因为我只想画一段曲线!工作得很好。

For my problem I set the t1 value to 0.5 and check if t is above/below this threshold, since I only want to draw one segment of the curve! Works out nicely.

这篇关于立方体样条:开始/结束段插值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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