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

标签 c# math linear-interpolation bicubic

<分区>

下面是三次插值函数:

public float Smooth(float start, float end, float amount)
{
    // Clamp to 0-1;
    amount = (amount > 1f) ? 1f : amount;
    amount = (amount < 0f) ? 0f : amount;

    // Cubicly adjust the amount value.
    amount = (amount * amount) * (3f - (2f * amount));

    return (start + ((end - start) * amount));
}

给定 0.0f - 1.0f 之间的量,此函数将在起始值和结束值之间进行立方插值。如果你要绘制这条曲线,你最终会得到这样的结果:

Expired Imageshack image removed

这里的三次函数是:

    amount = (amount * amount) * (3f - (2f * amount));

我如何调整它以产生两个进出切线?

要生成这样的曲线:(线性开始到立方结束)

Expired Imageshack image removed

作为一个函数

像另一个一样:(立方开始到线性结束)

Expired Imageshack image removed

有人有什么想法吗?提前致谢。

最佳答案

你想要的是一个Cubic Hermite Spline :

alt text

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

关于c# - C# 中的三次/曲线平滑插值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1146281/

相关文章:

c# - 我如何使用默认构造函数创建我的类的数组?

c++ - 数学 printf 式计算

c# - 为什么 -2 % 360 在 C# 中给出 -2 而不是 358

c# - 无效的 Swagger 安全定义

c# - 在响应中出现错误

c# - 为什么我的 GET 请求没有捕获任何 cookie?

python - 如何从 python 中的模块 `operator` 获取数学运算符字符串

c++ - 具有不同长度的两个 vector 数组的线性插值

java - 双线性插值异常

opengl - GL_LINEAR到底使用什么算法?