C# 中的三次/曲线平滑插值

发布于 2024-07-27 18:52:49 字数 1471 浏览 10 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

极致的悲 2024-08-03 18:52:49

你想要的是一个三次Hermite样条线

alt text

其中 p0 是起点,p1 是终点,m0 是起点切线,m1 是终点切线

What you want is a Cubic Hermite Spline:

alt text

where p0 is the start point, p1 is the end point, m0 is the start tangent, and m1 is the end tangent

终陌 2024-08-03 18:52:49

您可以进行线性插值和三次插值,并在两个插值函数之间进行插值。

IE。

cubic(t) = cubic interpolation
linear(t) = linear interpolation
cubic_to_linear(t) = linear(t)*t + cubic(t)*(1-t)
linear_to_cubic(t) = cubic(t)*t + linear(t)*(1-t)

其中 t 的范围为 0...1

you could have a linear interpolation and a cubic interpolation and interpolate between the two interpolation functions.

ie.

cubic(t) = cubic interpolation
linear(t) = linear interpolation
cubic_to_linear(t) = linear(t)*t + cubic(t)*(1-t)
linear_to_cubic(t) = cubic(t)*t + linear(t)*(1-t)

where t ranges from 0...1

纵情客 2024-08-03 18:52:49

好吧,一种简单的方法是这样的:

-Expand your function by 2 x and y
-Move 1 to the left and 1 down
Example: f(x) = -2x³+3x²
g(x) = 2 * [-2((x-1)/2)³+3((x-1)/2)²] - 1

或以编程方式(立方调整):

double amountsub1div2 = (amount + 1) / 2;
amount = -4 * amountsub1div2 * amountsub1div2 * amountsub1div2 + 6 * amountsub1div2 * amountsub1div2 - 1;

对于另一种,只需省略“移动”:

g(x) = 2 * [-2(x/2)³+3(x/2)²]

或以编程方式(立方调整):

double amountdiv2 = amount / 2;
amount = -4 * amountdiv2 * amountdiv2 * amountdiv2 + 6 * amountdiv2 * amountdiv2;

Well, a simple way would be this:

-Expand your function by 2 x and y
-Move 1 to the left and 1 down
Example: f(x) = -2x³+3x²
g(x) = 2 * [-2((x-1)/2)³+3((x-1)/2)²] - 1

Or programmatically (cubical adjusting):

double amountsub1div2 = (amount + 1) / 2;
amount = -4 * amountsub1div2 * amountsub1div2 * amountsub1div2 + 6 * amountsub1div2 * amountsub1div2 - 1;

For the other one, simply leave out the "moving":

g(x) = 2 * [-2(x/2)³+3(x/2)²]

Or programmatically (cubical adjusting):

double amountdiv2 = amount / 2;
amount = -4 * amountdiv2 * amountdiv2 * amountdiv2 + 6 * amountdiv2 * amountdiv2;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文