Skip to content

Instantly share code, notes, and snippets.

@tarjeihsch
Created December 20, 2023 13:00
Show Gist options
  • Save tarjeihsch/1ec8d9d0303529c9d5d55ce374abbbf3 to your computer and use it in GitHub Desktop.
Save tarjeihsch/1ec8d9d0303529c9d5d55ce374abbbf3 to your computer and use it in GitHub Desktop.
Hermite Interpolation
// https://en.wikipedia.org/wiki/Hermite_interpolation
inline FVector HermiteInterpolation(const FVector& P0, const FVector& P1, const FVector& V0, const FVector& V1, const float Alpha)
{
const float H1 = 2 * FMath::Pow(Alpha, 3) - 3 * FMath::Pow(Alpha, 2) + 1;
const float H2 = -2 * FMath::Pow(Alpha, 3) + 3 * FMath::Pow(Alpha, 2);
const float H3 = FMath::Pow(Alpha, 3) - 2 * FMath::Pow(Alpha, 2) + Alpha;
const float H4 = FMath::Pow(Alpha, 3) - FMath::Pow(Alpha, 2);
return H1 * P0 + H2 * P1 + H3 * V0 + H4 * V1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment