UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MathConst.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "Core/Types.h"
5
6namespace UE::CADKernel
7{
8UE_DEPRECATED(5.6, "Use FMath::GetMinMax instead.");
12template<typename ValueType> const void GetMinMax(const ValueType& ValueA, const ValueType& ValueB, ValueType& OutMin, ValueType& OutMax)
13{
14 FMath::GetMinMax(ValueA, ValueB, OutMin, OutMax);
15}
16
17UE_DEPRECATED(5.6, "Use FMath::GetMinMax instead.");
21template<typename ValueType> const void GetMinMax(ValueType& Min, ValueType& Max)
22{
23 FMath::GetMinMax(Min, Max);
24}
25
27template<typename ValueType> bool IsWithinExclusive(const ValueType& TestValue, const ValueType& MinValue, const ValueType& MaxValue)
28{
29 return ((TestValue > MinValue) && (TestValue < MaxValue));
30}
31
32inline int32 RealCompare(const double Value1, const double Value2, const double Tolerance = DOUBLE_SMALL_NUMBER)
33{
34 double Difference = Value1 - Value2;
35 if (Difference < -Tolerance)
36 {
37 return -1;
38 }
39 if (Difference > Tolerance)
40 {
41 return 1;
42 }
43 return 0;
44}
45
46template< class T >
47static T Cubic(const T A)
48{
49 return A * A * A;
50}
51
52template< class T >
54{
55 return FMath::Clamp((uint8)(Value / 255.), (uint8)0, (uint8)255);
56}
57
65inline double WrapTo(double Slope, const double StartOfPeriod, const double EndOfPeriod, const double PeriodLength)
66{
67 if (FMath::Abs(Slope) > DOUBLE_BIG_NUMBER)
68 {
69 return 0;
70 }
71
72 while (Slope < StartOfPeriod)
73 {
74 Slope += PeriodLength;
75 }
76 while (Slope >= EndOfPeriod)
77 {
78 Slope -= PeriodLength;
79 }
80 return Slope;
81}
82
83
84
85} // namespace UE::CADKernel
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
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
#define DOUBLE_SMALL_NUMBER
Definition UnrealMathUtility.h:72
#define DOUBLE_BIG_NUMBER
Definition UnrealMathUtility.h:74
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition CADEntity.cpp:23
uint8 ToUInt8(T Value)
Definition MathConst.h:53
bool IsWithinExclusive(const ValueType &TestValue, const ValueType &MinValue, const ValueType &MaxValue)
Definition MathConst.h:27
int32 RealCompare(const double Value1, const double Value2, const double Tolerance=DOUBLE_SMALL_NUMBER)
Definition MathConst.h:32
double WrapTo(double Slope, const double StartOfPeriod, const double EndOfPeriod, const double PeriodLength)
Definition MathConst.h:65
const void GetMinMax(const ValueType &ValueA, const ValueType &ValueB, ValueType &OutMin, ValueType &OutMax)
Definition MathConst.h:12
static constexpr UE_FORCEINLINE_HINT T Clamp(const T X, const T MinValue, const T MaxValue)
Definition UnrealMathUtility.h:592