# General QuestionDoes anyone know what this function is?

#### D-mo

##### Member
Orbiter Contributor
Code:
template <typename T> inline _constexpr_ T hermite(T a)
{
return a * a * (T(3) - T(2)*a);
}

It was added by @jarmonik in this commit: 213eabe70.

I thought maybe it's the same as std::hermite but the formulas are different.

#### n72.75

##### Move slow and break things
Orbiter Contributor
Tutorial Publisher
Donator
I think it is the same, it's just factored.

which if I'm not mistaken is the same as: std::hermite(3, x)

I know when I added gravity model stuff I wanted to used std::legendre, but it ended up not being exactly the function I needed. Not sure why here though. maybe it's faster, but I doubt it.

#### D-mo

##### Member
Orbiter Contributor
Hmm... if we rearrange it we get: return [imath]3a^2 - 2a^3[/imath]

but std::hermite(3, a) gives us: return [imath]8a^3 - 12a[/imath]

Or did I miss something? Sorry, my math skills are... let's just say they could use some improvement.

#### n72.75

##### Move slow and break things
Orbiter Contributor
Tutorial Publisher
Donator
I don't think you missed anything...

Reading your post, now I can't make sense of mine. I think it's trying to be the probabilistic Hermite function, whereas std::hermite would be the "Physicist Hermite". But it also still isn't quite the right equation. I don't understand what it's doing in the graphics client, some sort of lighting distribution function.

#### D-mo

##### Member
Orbiter Contributor
@n72.75 OK no problem. It's only used in one place:

Code:
FVECTOR4 vPlanet::AmbientApprox(FVECTOR3 vNrm, bool bR)
{
float dNS = -dot(vNrm, cp.toSun);
float fA = 1.0f - hermite(ilerp(0.0f, cp.TW_Dst, dNS));
float3 clr = (bR ? cp.RayWave : cp.cAmbient);
return float4(clr, fA);
}
I was thinking it could be replaced with the library function, but I guess I will leave it alone for now. At least until @jarmonik chimes in to clarify.

#### jarmonik

##### Well-known member
Orbiter Contributor
Beta Tester
Cubic Hermite Spline i.e. the same as smoothstep() function in HLSL. In other words "Hermite interpolation"

Replies
18
Views
530
Replies
0
Views
223
Replies
11
Views
662
Replies
13
Views
525
Replies
0
Views
149