UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
BezierUtilities.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Math/Vector.h"
6#include "Math/Box.h"
8
9namespace UE
10{
11namespace CubicBezier
12{
13
15inline FVector Eval(const FVector& P0, const FVector& P1, const FVector& P2, const FVector& P3, const float t)
16{
17 // Interpolate using De Casteljau algorithm.
18 const FVector P01 = FMath::Lerp(P0, P1, t);
19 const FVector P12 = FMath::Lerp(P1, P2, t);
20 const FVector P23 = FMath::Lerp(P2, P3, t);
21 const FVector P012 = FMath::Lerp(P01, P12, t);
22 const FVector P123 = FMath::Lerp(P12, P23, t);
23 return FMath::Lerp(P012, P123, t);
24}
25
27inline FVector EvalDerivate(const FVector& P0, const FVector& P1, const FVector& P2, const FVector& P3, const float t)
28{
29 const FVector P01 = FMath::Lerp(P0, P1, t);
30 const FVector P12 = FMath::Lerp(P1, P2, t);
31 const FVector P23 = FMath::Lerp(P2, P3, t);
32 return 3.0f * (FMath::Lerp(P12, P23, t) - FMath::Lerp(P01, P12, t));
33}
34
37ENGINE_API void SplitAt(const FVector& P0, const FVector& P1, const FVector& P2, const FVector& P3, const float t, FVector OutResult[5]);
38
40ENGINE_API FBox CalcBounds(const FVector& P0, const FVector& P1, const FVector& P2, const FVector& P3);
41
43ENGINE_API void ClosestPointApproximate(const FVector& FromPoint, const FVector& P0, const FVector& P1, const FVector& P2, const FVector& P3, FVector& OutClosestPoint, float& OutClosestT, const int Steps = 16);
44
46ENGINE_API void SegmentClosestPointApproximate(const FVector& SegStart, const FVector& SegEnd, const FVector& P0, const FVector& P1, const FVector& P2, const FVector& P3, FVector& OutClosestPoint, float& OutClosestT, const int Steps = 16);
47
49ENGINE_API float ArcLengthApproximate(const FVector& P0, const FVector& P1, const FVector& P2, const FVector& P3);
50
54ENGINE_API void Tessellate(TArray<FVector>& Output, const FVector& P0, const FVector& P1, const FVector& P2, const FVector& P3, const float Tolerance, const int MaxLevel = 6);
55
56} // namespace CubicBezier
57} // namespace UE
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition Array.h:670
FVector Eval(const FVector &P0, const FVector &P1, const FVector &P2, const FVector &P3, const float t)
Definition BezierUtilities.h:15
ENGINE_API FBox CalcBounds(const FVector &P0, const FVector &P1, const FVector &P2, const FVector &P3)
Definition BezierUtilities.cpp:26
ENGINE_API float ArcLengthApproximate(const FVector &P0, const FVector &P1, const FVector &P2, const FVector &P3)
Definition BezierUtilities.cpp:158
ENGINE_API void SplitAt(const FVector &P0, const FVector &P1, const FVector &P2, const FVector &P3, const float t, FVector OutResult[5])
Definition BezierUtilities.cpp:10
ENGINE_API void Tessellate(TArray< FVector > &Output, const FVector &P0, const FVector &P1, const FVector &P2, const FVector &P3, const float Tolerance, const int MaxLevel=6)
Definition BezierUtilities.cpp:207
FVector EvalDerivate(const FVector &P0, const FVector &P1, const FVector &P2, const FVector &P3, const float t)
Definition BezierUtilities.h:27
ENGINE_API void ClosestPointApproximate(const FVector &FromPoint, const FVector &P0, const FVector &P1, const FVector &P2, const FVector &P3, FVector &OutClosestPoint, float &OutClosestT, const int Steps=16)
Definition BezierUtilities.cpp:84
ENGINE_API void SegmentClosestPointApproximate(const FVector &SegStart, const FVector &SegEnd, const FVector &P0, const FVector &P1, const FVector &P2, const FVector &P3, FVector &OutClosestPoint, float &OutClosestT, const int Steps=16)
Definition BezierUtilities.cpp:120
Definition AdvancedWidgetsModule.cpp:13
static constexpr UE_FORCEINLINE_HINT T Lerp(const T &A, const T &B, const U &Alpha)
Definition UnrealMathUtility.h:1116