• ORBITER-FORUM will be temporarily closed at 2026-07-23 18:00 UTC while we complete some OF maintenance tasks. The amount of downtime is expected to take up to one hour, but probably less.

General Question Does anyone know what this function is?

D-mo

Member
Orbiter Contributor
Joined
Dec 11, 2014
Messages
43
Reaction score
8
Points
8
Location
US
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.
 
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.
 
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.
 
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.
 
@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.
 
Cubic Hermite Spline i.e. the same as smoothstep() function in HLSL. In other words "Hermite interpolation"
 
Back
Top