C++ 平滑步长函数

C++ 平滑步长函数,c++,interpolation,smoothstep,C++,Interpolation,Smoothstep,我正试图通过使用AMD提供的Smoothstep函数来获得一些结果,并将其绘制在一个图表上,该函数在这个维基百科页面上已经出现过。使用 下面是AMD[4]提供的C/C++示例实现 问题是我无法使用此方法,因为静态方法夹具不可用 我已导入以下内容: #include <math.h> #include <cmath> #include <algorithm> 可能只是缺少了名称空间“std”:下面是我编译的代码: #include <algori

我正试图通过使用AMD提供的
Smoothstep
函数来获得一些结果,并将其绘制在一个图表上,该函数在这个维基百科页面上已经出现过。使用

下面是AMD[4]提供的C/C++示例实现

问题是我无法使用此方法,因为
静态方法夹具
不可用

我已导入以下内容:

#include <math.h> 
#include <cmath> 
#include <algorithm>  

可能只是缺少了名称空间“std”:下面是我编译的代码:

#include <algorithm>

float smoothstep(float edge0, float edge1, float x) {
    // Scale, bias and saturate x to 0..1 range
    x = std::clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f);
    // Evaluate polynomial
    return x * x * (3 - 2 * x);
}
#包括
浮动平滑台阶(浮动边缘0、浮动边缘1、浮动x){
//缩放、偏置和饱和x至0..1范围
x=标准::夹具((x-边缘0)/(边缘1-边缘0),0.0f,1.0f);
//求值多项式
返回x*x*(3-2*x);
}

夹紧功能仅将第一个参数夹紧到第二个和第三个参数指定的间隔,即
夹紧(x,A,b)
只是
x=xb?b:x)
并进行额外检查,以确保
区域性?就像我说的,我的数学能力不是最好的。但是多亏了Thomas的评论,我将能够。注意:这需要C++17。
float linearIntepolate(float currentLocation, float Goal, float time){

    return (1 - time) * currentLocation + time * Goal;
}
#include <algorithm>

float smoothstep(float edge0, float edge1, float x) {
    // Scale, bias and saturate x to 0..1 range
    x = std::clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f);
    // Evaluate polynomial
    return x * x * (3 - 2 * x);
}