立方/曲线平滑插补在C# [英] Cubic/Curve Smooth Interpolation in C#

查看:558
本文介绍了立方/曲线平滑插补在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是一个三次插值功能:

Below is a cubic interpolation function:

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.0之间的量的开始和结束值之间立方插值的F - 1.0F。如果你绘制这条曲线,你会落得这样的:

This function will cubically interpolate between the start and end value given an amount between 0.0f - 1.0f. If you were to plot this curve, you'd end up with something like this:

过期Imageshack图像中删除

Expired Imageshack image removed

在这里三次函数为:

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



我如何调整这个生产两种产品切线和出?

How do I adjust this to produce two produce tangents in and out?

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

To produce curves like this: (Linear start to cubic end)

过期Imageshack图像中删除

Expired Imageshack image removed

作为一种功能

和这样作为另一个:(立方开始直线端)

and like this as another: (Cubic start to linear end)

过期Imageshack图像中删除

Expired Imageshack image removed

任何人有什么想法?先谢谢了。

Anyone got any ideas? Thanks in advance.

推荐答案

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

,其中P0为起点,p1为终点,M0为起始切线,而M1是终点切线

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

这篇关于立方/曲线平滑插补在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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