General Question Does anyone know what this function is?

D-mo

Member
Orbiter Contributor
Joined
Dec 11, 2014
Messages
43
Reaction score
7
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.
 

n72.75

Move slow and try not to break too much.
Orbiter Contributor
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 21, 2008
Messages
2,697
Reaction score
1,356
Points
128
Location
Saco, ME
Website
mwhume.space
Preferred Pronouns
he/him
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
Joined
Dec 11, 2014
Messages
43
Reaction score
7
Points
8
Location
US
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 try not to break too much.
Orbiter Contributor
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 21, 2008
Messages
2,697
Reaction score
1,356
Points
128
Location
Saco, ME
Website
mwhume.space
Preferred Pronouns
he/him
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
Joined
Dec 11, 2014
Messages
43
Reaction score
7
Points
8
Location
US
@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
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,668
Reaction score
796
Points
128
Cubic Hermite Spline i.e. the same as smoothstep() function in HLSL. In other words "Hermite interpolation"
 
Top