UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
CurveEvaluation.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Curves/RichCurve.h"
6
7namespace UE
8{
9 namespace Curves
10 {
11 /* Solve Cubic Euqation using Cardano's forumla
12 * Adopted from Graphic Gems 1
13 * https://github.com/erich666/GraphicsGems/blob/master/gems/Roots3And4.c
14 * Solve cubic of form
15 *
16 * @param Coeff Coefficient parameters of form Coeff[0] + Coeff[1]*x + Coeff[2]*x^2 + Coeff[3]*x^3 + Coeff[4]*x^4 = 0
17 * @param Solution Up to 3 real solutions. We don't include imaginary solutions, would need a complex number objecct
18 * @return Returns the number of real solutions returned in the Solution array.
19 */
20 ENGINE_API int32 SolveCubic(double Coeff[4], double Solution[3]);
21
25 template<typename CurveValueType>
26 CurveValueType BezierInterp(CurveValueType P0, CurveValueType P1, CurveValueType P2, CurveValueType P3, float Alpha)
27 {
28 const CurveValueType P01 = FMath::Lerp(P0, P1, Alpha);
29 const CurveValueType P12 = FMath::Lerp(P1, P2, Alpha);
30 const CurveValueType P23 = FMath::Lerp(P2, P3, Alpha);
31 const CurveValueType P012 = FMath::Lerp(P01, P12, Alpha);
32 const CurveValueType P123 = FMath::Lerp(P12, P23, Alpha);
33 const CurveValueType P0123 = FMath::Lerp(P012, P123, Alpha);
34
35 return P0123;
36 }
37
38 /*
39 * Convert the control values for a polynomial defined in the Bezier
40 * basis to a polynomial defined in the power basis (t^3 t^2 t 1).
41 */
42 ENGINE_API void BezierToPower(double A1, double B1, double C1, double D1, double* A2, double* B2, double* C2, double* D2);
43
45
48
50 bool IsWeighted(const FRichCurveKey& Key1, const FRichCurveKey& Key2);
51
53 ENGINE_API float EvalForTwoKeys(const FRichCurveKey& Key1, const FRichCurveKey& Key2, const float InTime);
54 }
55}
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
ERichCurveTangentWeightMode
Definition RichCurve.h:33
float WeightedEvalForTwoKeys(float Key1Value, float Key1Time, float Key1LeaveTangent, float Key1LeaveTangentWeight, ERichCurveTangentWeightMode Key1TangentWeightMode, float Key2Value, float Key2Time, float Key2ArriveTangent, float Key2ArriveTangentWeight, ERichCurveTangentWeightMode Key2TangentWeightMode, float InTime)
Definition CurveEvaluation.cpp:93
bool IsWeighted(const FRichCurveKey &Key1, const FRichCurveKey &Key2)
Definition CurveEvaluation.cpp:199
void BezierToPower(double A1, double B1, double C1, double D1, double *A2, double *B2, double *C2, double *D2)
Definition CurveEvaluation.cpp:81
CurveValueType BezierInterp(CurveValueType P0, CurveValueType P1, CurveValueType P2, CurveValueType P3, float Alpha)
Definition CurveEvaluation.h:26
float EvalForTwoKeys(const FRichCurveKey &Key1, const FRichCurveKey &Key2, const float InTime)
Definition CurveEvaluation.cpp:205
bool IsItNotWeighted(const FRichCurveKey &Key1, const FRichCurveKey &Key2)
Definition CurveEvaluation.cpp:193
int32 SolveCubic(double Coeff[4], double Solution[3])
Definition CurveEvaluation.cpp:10
Definition AdvancedWidgetsModule.cpp:13
static constexpr UE_FORCEINLINE_HINT T Lerp(const T &A, const T &B, const U &Alpha)
Definition UnrealMathUtility.h:1116
Definition RichCurve.h:81