UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Vector.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
7#include "Math/MathFwd.h" // IWYU pragma: export
9#include "Misc/Crc.h"
12#include "Misc/Parse.h"
14#include "Misc/NetworkVersion.h"
15#include "Math/Color.h"
16#include "Math/IntPoint.h"
17#include "Logging/LogMacros.h"
18#include "Math/Vector2D.h"
19#include "Misc/ByteSwap.h"
22#include "Math/IntVector.h"
23#include "Math/Axis.h"
26#include <type_traits>
27
28#if PLATFORM_ENABLE_VECTORINTRINSICS
29#include "Math/VectorRegister.h"
30#endif
31
32#ifdef _MSC_VER
33#pragma warning (push)
34// Ensure template functions don't generate shadowing warnings against global variables at the point of instantiation.
35#pragma warning (disable : 4459)
36#endif
37
38// Move out of global namespace to avoid collisions with Chaos::TVector within the physics code.
39namespace UE
40{
41namespace Math
42{
43
45
49template<typename T>
50struct TVector
51{
52 static_assert(std::is_floating_point_v<T>, "T must be floating point");
53
54public:
55 using FReal = T;
56
57 union
58 {
59 struct
60 {
62 T X;
63
65 T Y;
66
68 T Z;
69 };
70
71 UE_DEPRECATED(all, "For internal use only")
72 T XYZ[3];
73 };
74
77
80
83
86
89
92
95
98
101
104
107
110
113
115 [[nodiscard]] static inline TVector<T> One() { return OneVector; }
116
118 [[nodiscard]] static inline TVector<T> UnitX() { return XAxisVector; }
119
121 [[nodiscard]] static inline TVector<T> UnitY() { return YAxisVector; }
122
124 [[nodiscard]] static inline TVector<T> UnitZ() { return ZAxisVector; }
125
126public:
128#if ENABLE_NAN_DIAGNOSTIC
129 inline void DiagnosticCheckNaN() const
130 {
131 if (ContainsNaN())
132 {
133 logOrEnsureNanError(TEXT("FVector contains NaN: %s"), *ToString());
134 *const_cast<TVector<T>*>(static_cast<const TVector<T>*>(this)) = ZeroVector;
135 }
136 }
137
138 inline void DiagnosticCheckNaN(const TCHAR* Message) const
139 {
140 if (ContainsNaN())
141 {
142 logOrEnsureNanError(TEXT("%s: FVector contains NaN: %s"), Message, *ToString());
143 *const_cast<TVector<T>*>(static_cast<const TVector<T>*>(this)) = ZeroVector;
144 }
145 }
146#else
148 UE_FORCEINLINE_HINT void DiagnosticCheckNaN(const TCHAR* Message) const {}
149#endif
150
152 [[nodiscard]] TVector() = default;
153
159 [[nodiscard]] explicit inline TVector(T InF);
160
162
170 [[nodiscard]] inline TVector(T InX, T InY, T InZ);
171
178 [[nodiscard]] explicit inline TVector(const TVector2<T> V, T InZ);
179
185 [[nodiscard]] inline TVector(const UE::Math::TVector4<T>& V);
186
192 [[nodiscard]] explicit TVector(const FLinearColor& InColor);
193
199 template <typename IntType>
200 [[nodiscard]] explicit TVector(TIntVector3<IntType> InVector);
201
207 template <typename IntType>
209
215 [[nodiscard]] explicit inline TVector(EForceInit);
216
223 [[nodiscard]] inline TVector<T> operator^(const TVector<T>& V) const;
224
232
241
249
257
266
274
282
289 template<typename FArg UE_REQUIRES(std::is_arithmetic_v<FArg>)>
291 {
292 return TVector<T>(X - (T)Bias, Y - (T)Bias, Z - (T)Bias);
293 }
294
301 template<typename FArg UE_REQUIRES(std::is_arithmetic_v<FArg>)>
303 {
304 return TVector<T>(X + (T)Bias, Y + (T)Bias, Z + (T)Bias);
305 }
306
313 template<typename FArg UE_REQUIRES(std::is_arithmetic_v<FArg>)>
315 {
316 return TVector<T>(X * (T)Scale, Y * (T)Scale, Z * (T)Scale);
317 }
318
325 template<typename FArg UE_REQUIRES(std::is_arithmetic_v<FArg>)>
327 {
328 const T RScale = T(1) / Scale;
329 return TVector<T>(X * RScale, Y * RScale, Z * RScale);
330 }
331
339
347
348 // Binary comparison operators.
349
357
365
374
382
389
398
407
414 template<typename FArg UE_REQUIRES(std::is_arithmetic_v<FArg>)>
416 {
417 X *= Scale; Y *= Scale; Z *= Scale;
419 return *this;
420 }
421
428 template<typename FArg UE_REQUIRES(std::is_arithmetic_v<FArg>)>
430 {
431 const T RV = (T)1 / Scale;
432 X *= RV; Y *= RV; Z *= RV;
434 return *this;
435 }
436
444
452
460
468
477
485
493
496
499
500public:
501
502 // Simple functions.
503
511 void Set(T InX, T InY, T InZ);
512
518 [[nodiscard]] T GetMax() const;
519
525 [[nodiscard]] T GetAbsMax() const;
526
532 [[nodiscard]] T GetMin() const;
533
539 [[nodiscard]] T GetAbsMin() const;
540
543
546
553
559 [[nodiscard]] T Size() const;
560
566 [[nodiscard]] T Length() const;
567
573 [[nodiscard]] T SizeSquared() const;
574
581
587 [[nodiscard]] T Size2D() const ;
588
594 [[nodiscard]] T SizeSquared2D() const ;
595
602 [[nodiscard]] bool IsNearlyZero(T Tolerance=UE_KINDA_SMALL_NUMBER) const;
603
609 [[nodiscard]] bool IsZero() const;
610
618
624 [[nodiscard]] bool IsNormalized() const;
625
632 bool Normalize(T Tolerance=UE_SMALL_NUMBER);
633
641
650
659
668
676
683
691
699 [[nodiscard]] TVector<T> GridSnap(const T& GridSz) const;
700
707 [[nodiscard]] TVector<T> BoundToCube(T Radius) const;
708
711
714
717
720
723
730 void AddBounded(const TVector<T>& V, T Radius=MAX_int16);
731
739
746 [[nodiscard]] bool IsUniform(T Tolerance=UE_KINDA_SMALL_NUMBER) const;
747
755
763
772
781
788 [[nodiscard]] inline T CosineAngle2D(TVector<T> B) const;
789
797
805
814
826
838
847
850
856 bool ContainsNaN() const;
857
863 [[nodiscard]] FString ToString() const;
864
870 [[nodiscard]] FText ToText() const;
871
873 [[nodiscard]] FString ToCompactString() const;
874
877
885 bool InitFromString(const FString& InSourceString);
886
896
902
908 [[nodiscard]] T HeadingAngle() const;
909
918 [[nodiscard]] static CORE_API TVector<T> SlerpVectorToDirection(const TVector<T>& V, const TVector<T>& Direction, T Alpha);
919
929
940 static void CreateOrthonormalBasis(TVector<T>& XAxis,TVector<T>& YAxis,TVector<T>& ZAxis);
941
949 [[nodiscard]] static bool PointsAreSame(const TVector<T> &P, const TVector<T> &Q);
950
959 [[nodiscard]] static bool PointsAreNear(const TVector<T> &Point1, const TVector<T> &Point2, T Dist);
960
969 [[nodiscard]] static T PointPlaneDist(const TVector<T> &Point, const TVector<T> &PlaneBase, const TVector<T> &PlaneNormal);
970
979
989 [[nodiscard]] static TVector<T> PointPlaneProject(const TVector<T>& Point, const TVector<T>& A, const TVector<T>& B, const TVector<T>& C);
990
999 [[nodiscard]] static TVector<T> PointPlaneProject(const TVector<T>& Point, const TVector<T>& PlaneBase, const TVector<T>& PlaneNormal);
1000
1008 [[nodiscard]] static TVector<T> VectorPlaneProject(const TVector<T>& V, const TVector<T>& PlaneNormal);
1009
1017 [[nodiscard]] static UE_FORCEINLINE_HINT T Dist(const TVector<T> &V1, const TVector<T> &V2);
1019 {
1020 return Dist(V1, V2);
1021 }
1022
1030 [[nodiscard]] static UE_FORCEINLINE_HINT T DistXY(const TVector<T> &V1, const TVector<T> &V2);
1031 [[nodiscard]] static UE_FORCEINLINE_HINT T Dist2D(const TVector<T> &V1, const TVector<T> &V2)
1032 {
1033 return DistXY(V1, V2);
1034 }
1035
1044
1054 {
1055 return DistSquaredXY(V1, V2);
1056 }
1057
1066
1070 [[nodiscard]] static inline TVector<T> Min( const TVector<T>& A, const TVector<T>& B );
1071 [[nodiscard]] static inline TVector<T> Max( const TVector<T>& A, const TVector<T>& B );
1072
1073 [[nodiscard]] static inline TVector<T> Min3( const TVector<T>& A, const TVector<T>& B, const TVector<T>& C );
1074 [[nodiscard]] static inline TVector<T> Max3( const TVector<T>& A, const TVector<T>& B, const TVector<T>& C );
1075
1085
1095
1105
1117
1126 [[nodiscard]] static T Triple(const TVector<T>& X, const TVector<T>& Y, const TVector<T>& Z);
1127
1137
1145
1153
1164
1166 {
1167 Ar << *this;
1168 return true;
1169 }
1170
1172 {
1173 Slot << *this;
1174 return true;
1175 }
1176
1178 {
1179 if constexpr (std::is_same_v<T, float>)
1180 {
1181 return UE_SERIALIZE_VARIANT_FROM_MISMATCHED_TAG(Slot, Vector, Vector3f, Vector3d);
1182 }
1183 else
1184 {
1185 return UE_SERIALIZE_VARIANT_FROM_MISMATCHED_TAG(Slot, Vector, Vector3d, Vector3f);
1186 }
1187 }
1188
1195 bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess)
1196 {
1198
1200 {
1201 Ar << X << Y << Z;
1202 }
1203 else
1204 {
1205 checkf(Ar.IsLoading(), TEXT("float -> double conversion applied outside of load!"));
1206 // Always serialize as float
1207 float SX, SY, SZ;
1208 Ar << SX << SY << SZ;
1209 X = SX;
1210 Y = SY;
1211 Z = SZ;
1212 }
1213 return true;
1214 }
1215
1216 // Conversion from other type.
1217 template<typename FArg UE_REQUIRES(!std::is_same_v<T, FArg>)>
1218 explicit TVector(const TVector<FArg>& From) : TVector<T>((T)From.X, (T)From.Y, (T)From.Z) {}
1219};
1220
1228{
1229 // @warning BulkSerialize: FVector3f is serialized as memory dump
1230 // See TArray::BulkSerialize for detailed description of implied limitations.
1231 Ar << V.X << V.Y << V.Z;
1232
1234
1235 return Ar;
1236}
1237
1245{
1246 // @warning BulkSerialize: FVector3d is serialized as memory dump
1247 // See TArray::BulkSerialize for detailed description of implied limitations.
1249 {
1250 Ar << V.X;
1251 Ar << V.Y;
1252 Ar << V.Z;
1253 }
1254 else
1255 {
1256 checkf(Ar.IsLoading(), TEXT("float -> double conversion applied outside of load!"));
1257 // Stored as floats, so serialize float and copy.
1258 float X, Y, Z;
1259
1260 Ar << X;
1261 Ar << Y;
1262 Ar << Z;
1263
1264 V = TVector<double>(X, Y, Z);
1265 };
1266
1268
1269 return Ar;
1270}
1271
1280{
1281 // @warning BulkSerialize: FVector3f is serialized as memory dump
1282 // See TArray::BulkSerialize for detailed description of implied limitations.
1284 Record << SA_VALUE(TEXT("X"), V.X);
1285 Record << SA_VALUE(TEXT("Y"), V.Y);
1286 Record << SA_VALUE(TEXT("Z"), V.Z);
1288}
1289
1298{
1299 // @warning BulkSerialize: FVector3d is serialized as memory dump
1300 // See TArray::BulkSerialize for detailed description of implied limitations.
1302
1304 {
1305 Record << SA_VALUE(TEXT("X"), V.X);
1306 Record << SA_VALUE(TEXT("Y"), V.Y);
1307 Record << SA_VALUE(TEXT("Z"), V.Z);
1308 }
1309 else
1310 {
1311 checkf(Slot.GetUnderlyingArchive().IsLoading(), TEXT("float -> double conversion applied outside of load!"));
1312 // Stored as floats, so serialize float and copy.
1313 float X, Y, Z;
1314 Record << SA_VALUE(TEXT("X"), X);
1315 Record << SA_VALUE(TEXT("Y"), Y);
1316 Record << SA_VALUE(TEXT("Z"), Z);
1317 V = TVector<double>(X, Y, Z);
1318 }
1320}
1321
1322/* FVector inline functions
1323 *****************************************************************************/
1324
1325template<typename T>
1327 : X(V.X), Y(V.Y), Z(InZ)
1328{
1330}
1331
1332
1333
1334template<typename T>
1336{
1337 return RotateAngleAxisRad(FMath::DegreesToRadians(AngleDeg), Axis);
1338}
1339
1340template<typename T>
1342{
1343 T S, C;
1345
1346 const T XX = Axis.X * Axis.X;
1347 const T YY = Axis.Y * Axis.Y;
1348 const T ZZ = Axis.Z * Axis.Z;
1349
1350 const T XY = Axis.X * Axis.Y;
1351 const T YZ = Axis.Y * Axis.Z;
1352 const T ZX = Axis.Z * Axis.X;
1353
1354 const T XS = Axis.X * S;
1355 const T YS = Axis.Y * S;
1356 const T ZS = Axis.Z * S;
1357
1358 const T OMC = 1.f - C;
1359
1360 return TVector<T>(
1361 (OMC * XX + C) * X + (OMC * XY - ZS) * Y + (OMC * ZX + YS) * Z,
1362 (OMC * XY + ZS) * X + (OMC * YY + C) * Y + (OMC * YZ - XS) * Z,
1363 (OMC * ZX - YS) * X + (OMC * YZ + XS) * Y + (OMC * ZZ + C) * Z
1364 );
1365}
1366
1367template<typename T>
1368inline bool TVector<T>::PointsAreSame(const TVector<T>& P, const TVector<T>& Q)
1369{
1370 T Temp;
1371 Temp=P.X-Q.X;
1373 {
1374 Temp=P.Y-Q.Y;
1376 {
1377 Temp=P.Z-Q.Z;
1379 {
1380 return true;
1381 }
1382 }
1383 }
1384 return false;
1385}
1386
1387template<typename T>
1388inline bool TVector<T>::PointsAreNear(const TVector<T>& Point1, const TVector<T>& Point2, T Dist)
1389{
1390 T Temp;
1391 Temp=(Point1.X - Point2.X); if (FMath::Abs(Temp)>=Dist) return false;
1392 Temp=(Point1.Y - Point2.Y); if (FMath::Abs(Temp)>=Dist) return false;
1393 Temp=(Point1.Z - Point2.Z); if (FMath::Abs(Temp)>=Dist) return false;
1394 return true;
1395}
1396
1397template<typename T>
1399(
1400 const TVector<T> &Point,
1401 const TVector<T> &PlaneBase,
1402 const TVector<T> &PlaneNormal
1403)
1404{
1405 return (Point - PlaneBase) | PlaneNormal;
1406}
1407
1408
1409template<typename T>
1411{
1412 //Find the distance of X from the plane
1413 //Add the distance back along the normal from the point
1415}
1416
1417template<typename T>
1419{
1420 return V - V.ProjectOnToNormal(PlaneNormal);
1421}
1422
1423template<typename T>
1425{
1426 const T NormalDot = Normal1 | Normal2;
1427 return FMath::Abs(NormalDot) >= ParallelCosineThreshold;
1428}
1429
1430template<typename T>
1436
1437template<typename T>
1439{
1440 const T NormalDot = Normal1 | Normal2;
1441 return FMath::Abs(NormalDot) <= OrthogonalCosineThreshold;
1442}
1443
1444template<typename T>
1446{
1448 else if (FMath::Abs(TVector<T>::PointPlaneDist (Base2,Base1,Normal1)) > UE_THRESH_POINT_ON_PLANE) return false;
1449 else return true;
1450}
1451
1452template<typename T>
1453inline T TVector<T>::Triple(const TVector<T>& X, const TVector<T>& Y, const TVector<T>& Z)
1454{
1455 return
1456 ( (X.X * (Y.Y * Z.Z - Y.Z * Z.Y))
1457 + (X.Y * (Y.Z * Z.X - Y.X * Z.Z))
1458 + (X.Z * (Y.X * Z.Y - Y.Y * Z.X)));
1459}
1460
1461template<typename T>
1463{
1464 return RadVector * (180.f / UE_PI);
1465}
1466
1467template<typename T>
1469{
1470 return DegVector * (UE_PI / 180.f);
1471}
1472
1473template<typename T>
1475 : X(InF), Y(InF), Z(InF)
1476{
1478}
1479
1480template<typename T>
1485
1486template<typename T>
1488 : X(InX), Y(InY), Z(InZ)
1489{
1491}
1492
1493template<typename T>
1494inline TVector<T>::TVector(const FLinearColor& InColor)
1495 : X(InColor.R), Y(InColor.G), Z(InColor.B)
1496{
1498}
1499
1500template<typename T>
1501template <typename IntType>
1503 : X((T)InVector.X), Y((T)InVector.Y), Z((T)InVector.Z)
1504{
1506}
1507
1508template<typename T>
1509template <typename IntType>
1511 : X((T)A.X), Y((T)A.Y), Z(0.f)
1512{
1514}
1515
1516template<typename T>
1518 : X(0.0f), Y(0.0f), Z(0.0f)
1519{
1521}
1522
1523template<typename T>
1525{
1526 return TVector<T>
1527 (
1528 Y * V.Z - Z * V.Y,
1529 Z * V.X - X * V.Z,
1530 X * V.Y - Y * V.X
1531 );
1532}
1533
1534template<typename T>
1536{
1537 return *this ^ V;
1538}
1539
1540template<typename T>
1545
1546template<typename T>
1548{
1549 return X*V.X + Y*V.Y + Z*V.Z;
1550}
1551
1552template<typename T>
1554{
1555 return *this | V;
1556}
1557
1558template<typename T>
1560{
1561 return A | B;
1562}
1563
1564template<typename T>
1566{
1567 return TVector<T>(X + V.X, Y + V.Y, Z + V.Z);
1568}
1569
1570template<typename T>
1572{
1573 return TVector<T>(X - V.X, Y - V.Y, Z - V.Z);
1574}
1575
1576template<typename T>
1578{
1579 return TVector<T>(X * V.X, Y * V.Y, Z * V.Z);
1580}
1581
1582template<typename T>
1584{
1585 return TVector<T>(X / V.X, Y / V.Y, Z / V.Z);
1586}
1587
1588template<typename T>
1590{
1591 return X==V.X && Y==V.Y && Z==V.Z;
1592}
1593
1594template<typename T>
1596{
1597 return X!=V.X || Y!=V.Y || Z!=V.Z;
1598}
1599
1600template<typename T>
1601UE_FORCEINLINE_HINT bool TVector<T>::Equals(const TVector<T>& V, T Tolerance) const
1602{
1603 return FMath::Abs(X-V.X) <= Tolerance && FMath::Abs(Y-V.Y) <= Tolerance && FMath::Abs(Z-V.Z) <= Tolerance;
1604}
1605
1606template<typename T>
1608{
1609 return FMath::Abs(X - Y) <= Tolerance && FMath::Abs(X - Z) <= Tolerance && FMath::Abs(Y - Z) <= Tolerance;
1610}
1611
1612
1613template<typename T>
1615{
1616 return TVector<T>(-X, -Y, -Z);
1617}
1618
1619
1620template<typename T>
1622{
1623 X += V.X; Y += V.Y; Z += V.Z;
1624 DiagnosticCheckNaN();
1625 return *this;
1626}
1627
1628template<typename T>
1630{
1631 X -= V.X; Y -= V.Y; Z -= V.Z;
1632 DiagnosticCheckNaN();
1633 return *this;
1634}
1635
1636template<typename T>
1638{
1639 X *= V.X; Y *= V.Y; Z *= V.Z;
1640 DiagnosticCheckNaN();
1641 return *this;
1642}
1643
1644template<typename T>
1646{
1647 X /= V.X; Y /= V.Y; Z /= V.Z;
1648 DiagnosticCheckNaN();
1649 return *this;
1650}
1651
1652template<typename T>
1657
1658template<typename T>
1663
1664template<typename T>
1665inline void TVector<T>::Set(T InX, T InY, T InZ)
1666{
1667 X = InX;
1668 Y = InY;
1669 Z = InZ;
1670 DiagnosticCheckNaN();
1671}
1672
1673template<typename T>
1675{
1676 return FMath::Max(FMath::Max(X,Y),Z);
1677}
1678
1679template<typename T>
1681{
1682 return FMath::Max(FMath::Max(FMath::Abs(X),FMath::Abs(Y)),FMath::Abs(Z));
1683}
1684
1685template<typename T>
1687{
1688 return FMath::Min(FMath::Min(X,Y),Z);
1689}
1690
1691template<typename T>
1693{
1694 return FMath::Min(FMath::Min(FMath::Abs(X),FMath::Abs(Y)),FMath::Abs(Z));
1695}
1696
1697template<typename T>
1699{
1700 return TVector<T>(FMath::Min(X, Other.X), FMath::Min(Y, Other.Y), FMath::Min(Z, Other.Z));
1701}
1702
1703template<typename T>
1705{
1706 return TVector<T>(FMath::Max(X, Other.X), FMath::Max(Y, Other.Y), FMath::Max(Z, Other.Z));
1707}
1708
1709template<typename T>
1711{
1712 return TVector<T>(FMath::Abs(X), FMath::Abs(Y), FMath::Abs(Z));
1713}
1714
1715template<typename T>
1717{
1718 return FMath::Sqrt(X*X + Y*Y + Z*Z);
1719}
1720
1721template<typename T>
1723{
1724 return Size();
1725}
1726
1727template<typename T>
1729{
1730 return X*X + Y*Y + Z*Z;
1731}
1732
1733template<typename T>
1735{
1736 return SizeSquared();
1737}
1738
1739template<typename T>
1741{
1742 return FMath::Sqrt(X*X + Y*Y);
1743}
1744
1745template<typename T>
1747{
1748 return X*X + Y*Y;
1749}
1750
1751template<typename T>
1752inline bool TVector<T>::IsNearlyZero(T Tolerance) const
1753{
1754 return
1755 FMath::Abs(X)<=Tolerance
1756 && FMath::Abs(Y)<=Tolerance
1757 && FMath::Abs(Z)<=Tolerance;
1758}
1759
1760template<typename T>
1762{
1763 return X==0.f && Y==0.f && Z==0.f;
1764}
1765
1766template<typename T>
1767inline bool TVector<T>::Normalize(T Tolerance)
1768{
1769 const T SquareSum = X*X + Y*Y + Z*Z;
1770 if(SquareSum > Tolerance)
1771 {
1772 const T Scale = FMath::InvSqrt(SquareSum);
1773 X *= Scale; Y *= Scale; Z *= Scale;
1774 return true;
1775 }
1776 return false;
1777}
1778
1779template<typename T>
1781{
1782 return FMath::Abs(1.0f - SizeSquared()) < LengthSquaredTolerance;
1783}
1784
1785template<typename T>
1787{
1788 return (FMath::Abs(1.f - SizeSquared()) < UE_THRESH_VECTOR_NORMALIZED);
1789}
1790
1791template<typename T>
1793{
1794 OutLength = Size();
1796 {
1797 T OneOverLength = T(1.0 / OutLength);
1799 }
1800 else
1801 {
1802 OutDir = ZeroVector;
1803 }
1804}
1805
1806template<typename T>
1808{
1809 OutLength = (float)Size();
1811 {
1812 float OneOverLength = 1.0f / OutLength;
1814 }
1815 else
1816 {
1817 OutDir = ZeroVector;
1818 }
1819}
1820
1821
1822template<typename T>
1824{
1825 return TVector<T>
1826 (
1827 FMath::FloatSelect(X, (T)1, (T)-1), // LWC_TODO: Templatize FMath functionality
1828 FMath::FloatSelect(Y, (T)1, (T)-1),
1829 FMath::FloatSelect(Z, (T)1, (T)-1)
1830 );
1831}
1832
1833template<typename T>
1835{
1836 const T RZ = 1.f/Z;
1837 return TVector<T>(X*RZ, Y*RZ, 1);
1838}
1839
1840template<typename T>
1842{
1843 const T Scale = FMath::InvSqrt(X*X+Y*Y+Z*Z);
1844 return TVector<T>(X*Scale, Y*Scale, Z*Scale);
1845}
1846
1847template<typename T>
1849{
1850 const T Scale = FMath::InvSqrt(X * X + Y * Y);
1851 return TVector<T>(X*Scale, Y*Scale, 0);
1852}
1853
1854template<typename T>
1859
1860template<typename T>
1862{
1863 return TVector<T>
1864 (
1865 FMath::Clamp(X,-Radius,Radius),
1866 FMath::Clamp(Y,-Radius,Radius),
1867 FMath::Clamp(Z,-Radius,Radius)
1868 );
1869}
1870
1871template<typename T>
1873{
1874 return TVector<T>
1875 (
1876 FMath::Clamp(X, Min.X, Max.X),
1877 FMath::Clamp(Y, Min.Y, Max.Y),
1878 FMath::Clamp(Z, Min.Z, Max.Z)
1879 );
1880}
1881
1882
1883template<typename T>
1885{
1886 T VecSize = Size();
1887 const TVector<T> VecDir = (VecSize > UE_SMALL_NUMBER) ? (*this/VecSize) : ZeroVector;
1888
1890
1891 return VecSize * VecDir;
1892}
1893
1894template<typename T>
1896{
1897 T VecSize2D = Size2D();
1898 const TVector<T> VecDir = (VecSize2D > UE_SMALL_NUMBER) ? (*this/VecSize2D) : ZeroVector;
1899
1901
1902 return TVector<T>(VecSize2D * VecDir.X, VecSize2D * VecDir.Y, Z);
1903}
1904
1905template<typename T>
1907{
1909 {
1910 return ZeroVector;
1911 }
1912
1913 const T VSq = SizeSquared();
1914 if (VSq > FMath::Square(MaxSize))
1915 {
1916 const T Scale = MaxSize * FMath::InvSqrt(VSq);
1917 return TVector<T>(X*Scale, Y*Scale, Z*Scale);
1918 }
1919 else
1920 {
1921 return *this;
1922 }
1923}
1924
1925template<typename T>
1927{
1929 {
1930 return TVector<T>(0.f, 0.f, Z);
1931 }
1932
1933 const T VSq2D = SizeSquared2D();
1935 {
1936 const T Scale = MaxSize * FMath::InvSqrt(VSq2D);
1937 return TVector<T>(X*Scale, Y*Scale, Z);
1938 }
1939 else
1940 {
1941 return *this;
1942 }
1943}
1944
1945template<typename T>
1947{
1948 *this = (*this + V).BoundToCube(Radius);
1949}
1950
1951template<typename T>
1959
1960template<typename T>
1968
1969template<typename T>
1971{
1972 return (Index >= 0) && (Index < NumComponents);
1973}
1974
1975template<typename T>
1977{
1978 switch (Axis)
1979 {
1980 case EAxis::X:
1981 return X;
1982 case EAxis::Y:
1983 return Y;
1984 case EAxis::Z:
1985 return Z;
1986 case EAxis::None:
1987 default:
1988 return 0.f;
1989 }
1990}
1991
1992template<typename T>
1994{
1995 switch (Axis)
1996 {
1997 case EAxis::X:
1998 X = Component;
1999 break;
2000 case EAxis::Y:
2001 Y = Component;
2002 break;
2003 case EAxis::Z:
2004 Z = Component;
2005 break;
2006 case EAxis::None:
2007 default:
2008 break;
2009 }
2010}
2011
2012template<typename T>
2014{
2016 if (X!=0.f)
2017 {
2018 RecVector.X = 1.f/X;
2019 }
2020 else
2021 {
2023 }
2024 if (Y!=0.f)
2025 {
2026 RecVector.Y = 1.f/Y;
2027 }
2028 else
2029 {
2031 }
2032 if (Z!=0.f)
2033 {
2034 RecVector.Z = 1.f/Z;
2035 }
2036 else
2037 {
2039 }
2040
2041 return RecVector;
2042}
2043
2044
2045
2046
2047template<typename T>
2049{
2050 return AllComponentsEqual(Tolerance);
2051}
2052
2053template<typename T>
2055{
2056 return *this - MirrorNormal * (2.f * (*this | MirrorNormal));
2057}
2058
2059template<typename T>
2061{
2062 const T SquareSum = X*X + Y*Y + Z*Z;
2063
2064 // Not sure if it's safe to add tolerance in there. Might introduce too many errors
2065 if(SquareSum == 1.f)
2066 {
2067 return *this;
2068 }
2069 else if(SquareSum < Tolerance)
2070 {
2071 return ResultIfZero;
2072 }
2073 const T Scale = (T)FMath::InvSqrt(SquareSum);
2074 return TVector<T>(X*Scale, Y*Scale, Z*Scale);
2075}
2076
2077template<typename T>
2079{
2080 const T SquareSum = X*X + Y*Y;
2081
2082 // Not sure if it's safe to add tolerance in there. Might introduce too many errors
2083 if(SquareSum == 1.f)
2084 {
2085 if(Z == 0.f)
2086 {
2087 return *this;
2088 }
2089 else
2090 {
2091 return TVector<T>(X, Y, 0.f);
2092 }
2093 }
2094 else if(SquareSum < Tolerance)
2095 {
2096 return ResultIfZero;
2097 }
2098
2099 const T Scale = FMath::InvSqrt(SquareSum);
2100 return TVector<T>(X*Scale, Y*Scale, 0.f);
2101}
2102
2103template<typename T>
2105{
2106 TVector<T> A(*this);
2107 A.Z = 0.0f;
2108 B.Z = 0.0f;
2109 A.Normalize();
2110 B.Normalize();
2111 return A | B;
2112}
2113
2114template<typename T>
2116{
2117 return (A * ((*this | A) / (A | A)));
2118}
2119
2120template<typename T>
2125
2126
2127template<typename T>
2129{
2131 {
2134 };
2135
2136 // Check we have >0 points and clusters
2137 if (Points.Num() == 0 || Clusters.Num() == 0)
2138 {
2139 return;
2140 }
2141
2142 // Temp storage for each cluster that mirrors the order of the passed in Clusters array
2144 ClusterData.AddZeroed(Clusters.Num());
2145
2146 // Then iterate
2147 for (int32 ItCount = 0; ItCount < NumIterations; ItCount++)
2148 {
2149 // Classify each point - find closest cluster center
2150 for (int32 i = 0; i < Points.Num(); i++)
2151 {
2152 const TVector<T>& Pos = Points[i];
2153
2154 // Iterate over all clusters to find closes one
2157 for (int32 j = 0; j < Clusters.Num(); j++)
2158 {
2159 const T DistSqr = (Pos - Clusters[j]).SizeSquared();
2160 if (DistSqr < NearestClusterDistSqr)
2161 {
2162 NearestClusterDistSqr = DistSqr;
2164 }
2165 }
2166 // Update its info with this point
2168 {
2169 ClusterData[NearestClusterIndex].ClusterPosAccum += Pos;
2170 ClusterData[NearestClusterIndex].ClusterSize++;
2171 }
2172 }
2173
2174 // All points classified - update cluster center as average of membership
2175 for (int32 i = 0; i < Clusters.Num(); i++)
2176 {
2177 if (ClusterData[i].ClusterSize > 0)
2178 {
2179 Clusters[i] = ClusterData[i].ClusterPosAccum / (T)ClusterData[i].ClusterSize;
2180 }
2181 }
2182 }
2183
2184 // so now after we have possible cluster centers we want to remove the ones that are outliers and not part of the main cluster
2185 for (int32 i = 0; i < ClusterData.Num(); i++)
2186 {
2187 if (ClusterData[i].ClusterSize < NumConnectionsToBeValid)
2188 {
2189 Clusters.RemoveAt(i);
2190 }
2191 }
2192}
2193
2194template<typename T>
2196{
2198 check(NumPoints >= 2);
2199
2200 // var q is the change in t between successive evaluations.
2201 const T q = 1.f / (T)(NumPoints - 1); // q is dependent on the number of GAPS = POINTS-1
2202
2203 // recreate the names used in the derivation
2204 const TVector<T>& P0 = ControlPoints[0];
2205 const TVector<T>& P1 = ControlPoints[1];
2206 const TVector<T>& P2 = ControlPoints[2];
2207 const TVector<T>& P3 = ControlPoints[3];
2208
2209 // coefficients of the cubic polynomial that we're FDing -
2210 const TVector<T> a = P0;
2211 const TVector<T> b = 3 * (P1 - P0);
2212 const TVector<T> c = 3 * (P2 - 2 * P1 + P0);
2213 const TVector<T> d = P3 - 3 * P2 + 3 * P1 - P0;
2214
2215 // initial values of the poly and the 3 diffs -
2216 TVector<T> S = a; // the poly value
2217 TVector<T> U = b * q + c * q * q + d * q * q * q; // 1st order diff (quadratic)
2218 TVector<T> V = 2 * c * q * q + 6 * d * q * q * q; // 2nd order diff (linear)
2219 TVector<T> W = 6 * d * q * q * q; // 3rd order diff (constant)
2220
2221 // Path length.
2222 T Length = 0;
2223
2224 TVector<T> OldPos = P0;
2225 OutPoints.Add(P0); // first point on the curve is always P0.
2226
2227 for (int32 i = 1; i < NumPoints; ++i)
2228 {
2229 // calculate the next value and update the deltas
2230 S += U; // update poly value
2231 U += V; // update 1st order diff value
2232 V += W; // update 2st order diff value
2233 // 3rd order diff is constant => no update needed.
2234
2235 // Update Length.
2237 OldPos = S;
2238
2239 OutPoints.Add(S);
2240 }
2241
2242 // Return path length as experienced in sequence (linear interpolation between points).
2243 return Length;
2244}
2245
2246template<typename T>
2248{
2249 // Project the X and Y axes onto the plane perpendicular to the Z axis.
2250 XAxis -= (XAxis | ZAxis) / (ZAxis | ZAxis) * ZAxis;
2251 YAxis -= (YAxis | ZAxis) / (ZAxis | ZAxis) * ZAxis;
2252
2253 // If the X axis was parallel to the Z axis, choose a vector which is orthogonal to the Y and Z axes.
2254 if (XAxis.SizeSquared() < UE_DELTA * UE_DELTA)
2255 {
2256 XAxis = YAxis ^ ZAxis;
2257 }
2258
2259 // If the Y axis was parallel to the Z axis, choose a vector which is orthogonal to the X and Z axes.
2260 if (YAxis.SizeSquared() < UE_DELTA * UE_DELTA)
2261 {
2262 YAxis = XAxis ^ ZAxis;
2263 }
2264
2265 // Normalize the basis vectors.
2266 XAxis.Normalize();
2267 YAxis.Normalize();
2268 ZAxis.Normalize();
2269}
2270
2271template<typename T>
2278
2279template<typename T>
2281{
2282 const T NX = FMath::Abs(X);
2283 const T NY = FMath::Abs(Y);
2284 const T NZ = FMath::Abs(Z);
2285
2286 // Find best basis vectors.
2287 if (NZ > NX && NZ > NY) Axis1 = TVector<T>(1, 0, 0);
2288 else Axis1 = TVector<T>(0, 0, 1);
2289
2290 TVector<T> Tmp = Axis1 - *this * (Axis1 | *this);
2291 Axis1 = Tmp.GetSafeNormal();
2292 Axis2 = Axis1 ^ *this;
2293}
2294
2295template<typename T>
2296inline bool TVector<T>::ContainsNaN() const
2297{
2298 return (!FMath::IsFinite(X) ||
2299 !FMath::IsFinite(Y) ||
2300 !FMath::IsFinite(Z));
2301}
2302
2303template<typename T>
2305{
2306 return FString::Printf(TEXT("X=%3.3f Y=%3.3f Z=%3.3f"), X, Y, Z);
2307}
2308
2309template<typename T>
2311{
2313 Args.Add(TEXT("X"), X);
2314 Args.Add(TEXT("Y"), Y);
2315 Args.Add(TEXT("Z"), Z);
2316
2317 return FText::Format(NSLOCTEXT("Core", "Vector3", "X={X} Y={Y} Z={Z}"), Args);
2318}
2319
2320template<typename T>
2322{
2323 if (IsNearlyZero())
2324 {
2325 return NSLOCTEXT("Core", "Vector3_CompactZeroVector", "V(0)");
2326 }
2327
2328 const bool XIsNotZero = !FMath::IsNearlyZero(X);
2329 const bool YIsNotZero = !FMath::IsNearlyZero(Y);
2330 const bool ZIsNotZero = !FMath::IsNearlyZero(Z);
2331
2334 FormatRules.MinimumIntegralDigits = 0;
2335
2337 Args.Add(TEXT("X"), FText::AsNumber(X, &FormatRules));
2338 Args.Add(TEXT("Y"), FText::AsNumber(Y, &FormatRules));
2339 Args.Add(TEXT("Z"), FText::AsNumber(Z, &FormatRules));
2340
2341 if (XIsNotZero && YIsNotZero && ZIsNotZero)
2342 {
2343 return FText::Format(NSLOCTEXT("Core", "Vector3_CompactXYZ", "V(X={X}, Y={Y}, Z={Z})"), Args);
2344 }
2345 else if (!XIsNotZero && YIsNotZero && ZIsNotZero)
2346 {
2347 return FText::Format(NSLOCTEXT("Core", "Vector3_CompactYZ", "V(Y={Y}, Z={Z})"), Args);
2348 }
2349 else if (XIsNotZero && !YIsNotZero && ZIsNotZero)
2350 {
2351 return FText::Format(NSLOCTEXT("Core", "Vector3_CompactXZ", "V(X={X}, Z={Z})"), Args);
2352 }
2353 else if (XIsNotZero && YIsNotZero && !ZIsNotZero)
2354 {
2355 return FText::Format(NSLOCTEXT("Core", "Vector3_CompactXY", "V(X={X}, Y={Y})"), Args);
2356 }
2357 else if (!XIsNotZero && !YIsNotZero && ZIsNotZero)
2358 {
2359 return FText::Format(NSLOCTEXT("Core", "Vector3_CompactZ", "V(Z={Z})"), Args);
2360 }
2361 else if (XIsNotZero && !YIsNotZero && !ZIsNotZero)
2362 {
2363 return FText::Format(NSLOCTEXT("Core", "Vector3_CompactX", "V(X={X})"), Args);
2364 }
2365 else if (!XIsNotZero && YIsNotZero && !ZIsNotZero)
2366 {
2367 return FText::Format(NSLOCTEXT("Core", "Vector3_CompactY", "V(Y={Y})"), Args);
2368 }
2369
2370 return NSLOCTEXT("Core", "Vector3_CompactZeroVector", "V(0)");
2371}
2372
2373template<typename T>
2374inline FString TVector<T>::ToCompactString() const
2375{
2376 if(IsNearlyZero())
2377 {
2378 return FString(TEXT("V(0)"));
2379 }
2380
2381 FString ReturnString(TEXT("V("));
2382 bool bIsEmptyString = true;
2384 {
2385 ReturnString += FString::Printf(TEXT("X=%.2f"), X);
2386 bIsEmptyString = false;
2387 }
2389 {
2390 if(!bIsEmptyString)
2391 {
2392 ReturnString += FString(TEXT(", "));
2393 }
2394 ReturnString += FString::Printf(TEXT("Y=%.2f"), Y);
2395 bIsEmptyString = false;
2396 }
2398 {
2399 if(!bIsEmptyString)
2400 {
2401 ReturnString += FString(TEXT(", "));
2402 }
2403 ReturnString += FString::Printf(TEXT("Z=%.2f"), Z);
2404 bIsEmptyString = false;
2405 }
2406 ReturnString += FString(TEXT(")"));
2407 return ReturnString;
2408}
2409
2410template<typename T>
2412{
2413 X = Y = Z = 0;
2414
2415 if (FCString::Strifind(*InSourceString, TEXT("V(0)")) != nullptr)
2416 {
2417 return true;
2418 }
2419
2420 const bool bSuccessful = FParse::Value(*InSourceString, TEXT("X="), X) | FParse::Value(*InSourceString, TEXT("Y="), Y) | FParse::Value(*InSourceString, TEXT("Z="), Z); //-V792
2421
2422 return bSuccessful;
2423}
2424
2425template<typename T>
2427{
2428 X = Y = Z = 0;
2429
2430 // The initialization is only successful if the X, Y, and Z values can all be parsed from the string
2431 const bool bSuccessful = FParse::Value(*InSourceString, TEXT("X=") , X) && FParse::Value(*InSourceString, TEXT("Y="), Y) && FParse::Value(*InSourceString, TEXT("Z="), Z);
2432
2433 return bSuccessful;
2434}
2435
2436template<typename T>
2438{
2439 checkSlow(IsUnit());
2440 const T Theta = FMath::Acos(Z / Size());
2441 const T Phi = FMath::Atan2(Y, X);
2442 return TVector2<T>(Theta, Phi);
2443}
2444
2445template<typename T>
2447{
2448 // Project Dir into Z plane.
2449 TVector<T> PlaneDir = *this;
2450 PlaneDir.Z = 0.f;
2451 PlaneDir = PlaneDir.GetSafeNormal();
2452
2453 T Angle = FMath::Acos(PlaneDir.X);
2454
2455 if(PlaneDir.Y < 0.0f)
2456 {
2457 Angle *= -1.0f;
2458 }
2459
2460 return Angle;
2461}
2462
2463
2464
2465template<typename T>
2467{
2468 return FMath::Sqrt(TVector<T>::DistSquared(V1, V2));
2469}
2470
2471template<typename T>
2473{
2474 return FMath::Sqrt(TVector<T>::DistSquaredXY(V1, V2));
2475}
2476
2477template<typename T>
2479{
2480 return FMath::Square(V2.X-V1.X) + FMath::Square(V2.Y-V1.Y) + FMath::Square(V2.Z-V1.Z);
2481}
2482
2483template<typename T>
2485{
2486 return FMath::Square(V2.X-V1.X) + FMath::Square(V2.Y-V1.Y);
2487}
2488
2489template<typename T>
2491{
2492 return FMath::Abs(Normal.X*Size.X) + FMath::Abs(Normal.Y*Size.Y) + FMath::Abs(Normal.Z*Size.Z);
2493}
2494
2495template<typename T>
2497{
2498 return TVector<T>(
2499 FMath::Min( A.X, B.X ),
2500 FMath::Min( A.Y, B.Y ),
2501 FMath::Min( A.Z, B.Z )
2502 );
2503}
2504
2505template<typename T>
2507{
2508 return TVector<T>(
2509 FMath::Max( A.X, B.X ),
2510 FMath::Max( A.Y, B.Y ),
2511 FMath::Max( A.Z, B.Z )
2512 );
2513}
2514
2515template<typename T>
2517{
2518 return TVector<T>(
2519 FMath::Min3( A.X, B.X, C.X ),
2520 FMath::Min3( A.Y, B.Y, C.Y ),
2521 FMath::Min3( A.Z, B.Z, C.Z )
2522 );
2523}
2524
2525template<typename T>
2527{
2528 return TVector<T>(
2529 FMath::Max3( A.X, B.X, C.X ),
2530 FMath::Max3( A.Y, B.Y, C.Y ),
2531 FMath::Max3( A.Z, B.Z, C.Z )
2532 );
2533}
2534
2535#if !defined(_MSC_VER) || defined(__clang__) // MSVC can't forward declare explicit specializations
2537template<> CORE_API const FVector3f FVector3f::OneVector;
2538template<> CORE_API const FVector3f FVector3f::UpVector;
2548template<> CORE_API const FVector3d FVector3d::OneVector;
2549template<> CORE_API const FVector3d FVector3d::UpVector;
2558#endif
2559
2567template<typename T, typename T2 UE_REQUIRES(std::is_arithmetic_v<T2>)>
2569{
2570 return V.operator*(Scale);
2571}
2572
2579template<typename T>
2581{
2582 // Note: this assumes there's no padding in Vector that could contain uncompared data.
2583 return FCrc::MemCrc_DEPRECATED(&Vector, sizeof(Vector));
2584}
2585
2586} // namespace UE::Math
2587} // namespace UE
2588
2589template<> struct TCanBulkSerialize<FVector3f> { enum { Value = true }; };
2590template<> struct TIsPODType<FVector3f> { enum { Value = true }; };
2591template<> struct TIsUECoreVariant<FVector3f> { enum { Value = true }; };
2593
2594template<> struct TCanBulkSerialize<FVector3d> { enum { Value = true }; };
2595template<> struct TIsPODType<FVector3d> { enum { Value = true }; };
2596template<> struct TIsUECoreVariant<FVector3d> { enum { Value = true }; };
2598
2600template<typename T>
2602{
2603 return UE::Math::TVector<T>(
2604 FMath::Clamp(V.X, Min.X, Max.X),
2605 FMath::Clamp(V.Y, Min.Y, Max.Y),
2606 FMath::Clamp(V.Z, Min.Z, Max.Z)
2607 );
2608}
2609
2610#if PLATFORM_LITTLE_ENDIAN
2611#define INTEL_ORDER_VECTOR(x) (x)
2612#else
2613template<typename T>
2615{
2617}
2618#endif
2619
2620
2629template<typename T, typename U>
2631{
2632 // Accumulates the distance as we iterate axis
2633 T DistSquared = 0;
2634
2635 // Check each axis for min/max and add the distance accordingly
2636 // NOTE: Loop manually unrolled for > 2x speed up
2637 if (Point.X < Mins.X)
2638 {
2639 DistSquared += FMath::Square(Point.X - Mins.X);
2640 }
2641 else if (Point.X > Maxs.X)
2642 {
2643 DistSquared += FMath::Square(Point.X - Maxs.X);
2644 }
2645
2646 if (Point.Y < Mins.Y)
2647 {
2648 DistSquared += FMath::Square(Point.Y - Mins.Y);
2649 }
2650 else if (Point.Y > Maxs.Y)
2651 {
2652 DistSquared += FMath::Square(Point.Y - Maxs.Y);
2653 }
2654
2655 if (Point.Z < Mins.Z)
2656 {
2657 DistSquared += FMath::Square(Point.Z - Mins.Z);
2658 }
2659 else if (Point.Z > Maxs.Z)
2660 {
2661 DistSquared += FMath::Square(Point.Z - Maxs.Z);
2662 }
2663
2664 return DistSquared;
2665}
2666
2667
2668/* FMath inline functions
2669 *****************************************************************************/
2670
2671template<typename T>
2673 (
2674 const UE::Math::TVector<T>&Point1,
2675 const UE::Math::TVector<T>&Point2,
2676 const UE::Math::TVector<T>&PlaneOrigin,
2677 const UE::Math::TVector<T>&PlaneNormal
2678 )
2679{
2680 return
2681 Point1
2682 + (Point2 - Point1)
2683 * (((PlaneOrigin - Point1)|PlaneNormal) / ((Point2 - Point1)|PlaneNormal));
2684}
2685
2686template<typename T>
2687inline bool FMath::LineSphereIntersection(const UE::Math::TVector<T>& Start, const UE::Math::TVector<T>& Dir, T Length, const UE::Math::TVector<T>& Origin, T Radius)
2688{
2689 const UE::Math::TVector<T> EO = Start - Origin;
2690 const T v = (Dir | (Origin - Start));
2691 const T disc = Radius * Radius - ((EO | EO) - v * v);
2692
2693 if(disc >= 0)
2694 {
2695 const T Time = (v - Sqrt(disc)) / Length;
2696
2697 if(Time >= 0 && Time <= 1)
2698 return 1;
2699 else
2700 return 0;
2701 }
2702 else
2703 return 0;
2704}
2705
2707{
2708 FVector Result;
2710
2711 do
2712 {
2713 // Check random vectors in the unit sphere so result is statistically uniform.
2714 Result.X = FRand() * 2.f - 1.f;
2715 Result.Y = FRand() * 2.f - 1.f;
2716 Result.Z = FRand() * 2.f - 1.f;
2717 L = Result.SizeSquared();
2718 }
2719 while(L > 1.0f || L < UE_KINDA_SMALL_NUMBER);
2720
2721 return Result * (1.0f / Sqrt(L));
2722}
2723
2724/* TVector2<T> inline functions
2725 *****************************************************************************/
2726namespace UE {
2727namespace Math {
2728
2729template<typename InIntType>
2730template <typename FloatType>
2732{
2733 if constexpr (std::is_same_v<IntType, int32>)
2734 {
2735 X = FMath::TruncToInt32(InVector.X);
2736 Y = FMath::TruncToInt32(InVector.Y);
2737 Z = FMath::TruncToInt32(InVector.Z);
2738 }
2739 else if constexpr (std::is_same_v<IntType, uint32>)
2740 {
2741 X = IntCastChecked<uint32, int64>(FMath::TruncToInt64(InVector.X));
2742 Y = IntCastChecked<uint32, int64>(FMath::TruncToInt64(InVector.Y));
2743 Z = IntCastChecked<uint32, int64>(FMath::TruncToInt64(InVector.Z));
2744 }
2745 else
2746 {
2747 static_assert(sizeof(IntType) == 0, "Unimplemented");
2748 }
2749}
2750
2751template<typename T>
2753 : X(V.X), Y(V.Y)
2754{
2756}
2757
2758template<typename T>
2760{
2761 const T SinTheta = FMath::Sin(X);
2762 return TVector<T>(FMath::Cos(Y) * SinTheta, FMath::Sin(Y) * SinTheta, FMath::Cos(X));
2763}
2764
2765} // namespace UE::Math
2766
2767namespace LWC
2768{
2769inline constexpr FVector::FReal DefaultFloatPrecision = 1./16.;
2770
2771// Validated narrowing cast for world positions. FVector -> FVector3f
2780
2781// Validated narrowing cast for world positions. FVector -> FVector3f
2790
2791} // namespace UE::LWC
2792
2793} // namespace UE
2794
2795#if PLATFORM_ENABLE_VECTORINTRINSICS
2796template<>
2797inline FVector FMath::CubicInterp(const FVector& P0, const FVector& T0, const FVector& P1, const FVector& T1, const float& A)
2798{
2799 static_assert(PLATFORM_ENABLE_VECTORINTRINSICS == 1, "Requires vector intrinsics.");
2800 FVector res;
2801
2802 const float A2 = A * A;
2803 const float A3 = A2 * A;
2804
2805 const float s0 = (2 * A3) - (3 * A2) + 1;
2806 const float s1 = A3 - (2 * A2) + A;
2807 const float s2 = (A3 - A2);
2808 const float s3 = (-2 * A3) + (3 * A2);
2809
2814
2815 VectorStoreFloat3(VectorAdd(v0, v1), &res);
2816
2817 return res;
2818}
2819#endif
2820
2821#ifdef _MSC_VER
2822#pragma warning (pop)
2823#endif
@ Normal
Definition AndroidInputInterface.h:116
#define PLATFORM_ENABLE_VECTORINTRINSICS
Definition AndroidPlatform.h:72
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define INTEL_ORDERF(x)
Definition ByteSwap.h:141
@ INDEX_NONE
Definition CoreMiscDefines.h:150
EForceInit
Definition CoreMiscDefines.h:154
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
T ComputeSquaredDistanceFromBoxToPoint(const UE::Math::TVector< T > &Mins, const UE::Math::TVector< T > &Maxs, const UE::Math::TVector< U > &Point)
Definition Vector.h:2630
UE::Math::TVector< T > ClampVector(const UE::Math::TVector< T > &V, const UE::Math::TVector< T > &Min, const UE::Math::TVector< T > &Max)
Definition Vector.h:2601
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define X(Name, Desc)
Definition FormatStringSan.h:47
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
#define NSLOCTEXT(InNamespace, InKey, InTextLiteral)
Definition Internationalization.h:300
#define UE_SERIALIZE_VARIANT_FROM_MISMATCHED_TAG(AR_OR_SLOT, ALIAS, TYPE, ALT_TYPE)
Definition LargeWorldCoordinatesSerializer.h:9
#define logOrEnsureNanError(_FormatString_,...)
Definition LogMacros.h:436
#define DECLARE_INTRINSIC_TYPE_LAYOUT(T)
Definition MemoryLayout.h:760
#define MAX_int16
Definition NumericLimits.h:24
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
#define SA_VALUE(Name, Value)
Definition StructuredArchiveNameHelpers.h:77
FORCEINLINE VectorRegister4Double VectorLoadFloat3(const double *Ptr)
Definition UnrealMathFPU.h:427
FORCEINLINE VectorRegister4Float VectorMultiply(const VectorRegister4Float &Vec1, const VectorRegister4Float &Vec2)
Definition UnrealMathFPU.h:758
FORCEINLINE VectorRegister4Float VectorLoadFloat1(const float *Ptr)
Definition UnrealMathFPU.h:468
FORCEINLINE VectorRegister4Float VectorMultiplyAdd(const VectorRegister4Float &Vec1, const VectorRegister4Float &Vec2, const VectorRegister4Float &Vec3)
Definition UnrealMathFPU.h:786
FORCEINLINE VectorRegister4Float VectorAdd(const VectorRegister4Float &Vec1, const VectorRegister4Float &Vec2)
Definition UnrealMathFPU.h:704
FORCEINLINE void VectorStoreFloat3(const VectorRegister4Float &Vec, float *Dst)
Definition UnrealMathFPU.h:594
#define UE_THRESH_NORMALS_ARE_ORTHOGONAL
Definition UnrealMathUtility.h:212
#define UE_THRESH_POINTS_ARE_SAME
Definition UnrealMathUtility.h:201
#define UE_PI
Definition UnrealMathUtility.h:129
#define UE_BIG_NUMBER
Definition UnrealMathUtility.h:132
#define UE_SMALL_NUMBER
Definition UnrealMathUtility.h:130
#define UE_THRESH_NORMALS_ARE_PARALLEL
Definition UnrealMathUtility.h:211
#define UE_THRESH_VECTOR_NORMALIZED
Definition UnrealMathUtility.h:214
#define UE_THRESH_POINT_ON_PLANE
Definition UnrealMathUtility.h:199
#define UE_KINDA_SMALL_NUMBER
Definition UnrealMathUtility.h:131
#define UE_DELTA
Definition UnrealMathUtility.h:186
uint32 Size
Definition VulkanMemory.cpp:4034
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
virtual CORE_API uint32 EngineNetVer() const
Definition Archive.cpp:1497
virtual CORE_API void UsingCustomVersion(const struct FGuid &Guid)
Definition Archive.cpp:590
UE_FORCEINLINE_HINT bool IsLoading() const
Definition Archive.h:236
UE_FORCEINLINE_HINT FPackageFileVersion UEVer() const
Definition Archive.h:204
Definition NameTypes.h:617
Definition StructuredArchiveSlots.h:144
Definition StructuredArchiveSlots.h:52
UE_API FStructuredArchiveRecord EnterRecord()
Definition StructuredArchiveSlots.h:252
Definition Text.h:385
static CORE_API FText AsNumber(float Val, const FNumberFormattingOptions *const Options=NULL, const FCulturePtr &TargetCulture=NULL)
static CORE_API FText Format(FTextFormat Fmt, const FFormatNamedArguments &InArguments)
Definition Text.cpp:469
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
void RemoveAt(SizeType Index, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2083
SizeType AddZeroed()
Definition Array.h:2755
UE_FORCEINLINE_HINT ValueType & Add(const KeyType &InKey, const ValueType &InValue)
Definition SortedMap.h:194
CORE_API FArchive & GetUnderlyingArchive() const
Definition StructuredArchiveSlots.cpp:7
Definition CoreNet.h:191
Type
Definition Axis.h:11
@ Z
Definition Axis.h:15
@ Y
Definition Axis.h:14
@ X
Definition Axis.h:13
@ None
Definition Axis.h:12
FVector3f NarrowWorldPositionChecked(const FVector &WorldPosition)
Definition Vector.h:2772
constexpr FVector::FReal DefaultFloatPrecision
Definition Vector.h:2769
uint32 GetTypeHash(const TBox< T > &Box)
Definition Box.h:1008
FArchive & operator<<(FArchive &Ar, TBoxSphereBounds< float, float > &Bounds)
Definition BoxSphereBounds.h:396
UE_FORCEINLINE_HINT TQuat< T > operator*(const float Scale, const TQuat< T > &Q)
Definition Quat.h:1055
Definition AdvancedWidgetsModule.cpp:13
float v
Definition radaudio_mdct.cpp:62
U16 Index
Definition radfft.cpp:71
static CORE_API uint32 MemCrc_DEPRECATED(const void *Data, int32 Length, uint32 CRC=0)
Definition Crc.cpp:592
CORE_API static const FGuid Guid
Definition EngineNetworkCustomVersion.h:106
@ SerializeDoubleVectorsAsDoubles
Definition EngineNetworkCustomVersion.h:77
@ Ver21AndViewPitchOnly_DONOTUSE
Definition EngineNetworkCustomVersion.h:81
Definition Color.h:48
static constexpr UE_FORCEINLINE_HINT auto DegreesToRadians(T const &DegVal) -> decltype(DegVal *(UE_PI/180.f))
Definition UnrealMathUtility.h:871
static UE::Math::TVector< FReal > LinePlaneIntersection(const UE::Math::TVector< FReal > &Point1, const UE::Math::TVector< FReal > &Point2, const UE::Math::TVector< FReal > &PlaneOrigin, const UE::Math::TVector< FReal > &PlaneNormal)
static constexpr void SinCos(std::decay_t< T > *ScalarSin, std::decay_t< T > *ScalarCos, T Value)
Definition UnrealMathUtility.h:753
static constexpr T CubicInterp(const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
Definition UnrealMathUtility.h:1212
static constexpr UE_FORCEINLINE_HINT T Square(const T A)
Definition UnrealMathUtility.h:578
static bool LineSphereIntersection(const UE::Math::TVector< FReal > &Start, const UE::Math::TVector< FReal > &Dir, FReal Length, const UE::Math::TVector< FReal > &Origin, FReal Radius)
static FVector VRand()
Definition Vector.h:2706
static constexpr UE_FORCEINLINE_HINT T Clamp(const T X, const T MinValue, const T MaxValue)
Definition UnrealMathUtility.h:592
static constexpr UE_FORCEINLINE_HINT T Min3(const T A, const T B, const T C)
Definition UnrealMathUtility.h:558
static UE_FORCEINLINE_HINT bool IsNearlyZero(float Value, float ErrorTolerance=UE_SMALL_NUMBER)
Definition UnrealMathUtility.h:407
static constexpr UE_FORCEINLINE_HINT T Max3(const T A, const T B, const T C)
Definition UnrealMathUtility.h:551
static constexpr T UnwindDegrees(T A)
Definition UnrealMathUtility.h:944
static constexpr UE_FORCEINLINE_HINT T GridSnap(T Location, T Grid)
Definition UnrealMathUtility.h:685
Definition Text.h:199
int32 MinimumFractionalDigits
Definition Text.h:220
static CORE_API bool Value(const TCHAR *Stream, const TCHAR *Match, FName &Name)
Definition Parse.cpp:584
static const CharType * Strifind(const CharType *Str, const CharType *Find, bool bSkipQuotedChars=false)
Definition CString.h:692
Definition Array.h:45
@ Value
Definition Array.h:46
Definition IsPODType.h:12
@ Value
Definition IsPODType.h:13
Definition IsUECoreType.h:19
@ Value
Definition IsUECoreType.h:20
Definition IntPoint.h:25
Definition IntVector.h:22
InIntType IntType
Definition IntVector.h:23
Definition Plane.h:35
Definition Quat.h:39
Definition Rotator.h:37
Definition Vector2D.h:38
TVector< T > SphericalToUnitCartesian() const
Definition Vector.h:2759
UE_FORCEINLINE_HINT void DiagnosticCheckNaN()
Definition Vector2D.h:683
Definition Vector4.h:30
Definition Vector.h:44
Definition Vector.h:51
bool InitFromCompactString(const FString &InSourceString)
Definition Vector.h:2411
TVector< T > ComponentMin(const TVector< T > &Other) const
Definition Vector.h:1698
TVector2< T > UnitCartesianToSpherical() const
Definition Vector.h:2437
T & operator[](int32 Index)
Definition Vector.h:1653
TVector< T > operator*=(FArg Scale)
Definition Vector.h:415
static TVector< T > DegreesToRadians(const TVector< T > &DegVector)
Definition Vector.h:1468
static CORE_API const TVector< T > DownVector
Definition Vector.h:88
static TVector< T > UnitX()
Definition Vector.h:118
static constexpr int32 NumComponents
Definition Vector.h:76
UE_FORCEINLINE_HINT TVector< T > ProjectOnToNormal(const TVector< T > &Normal) const
Definition Vector.h:2121
void ToDirectionAndLength(TVector< T > &OutDir, float &OutLength) const
Definition Vector.h:1807
UE_FORCEINLINE_HINT TVector< T > operator-(const TVector< T > &V) const
Definition Vector.h:1571
static TVector< T > One()
Definition Vector.h:115
bool InitFromString(const FString &InSourceString)
Definition Vector.h:2426
bool NetSerialize(FArchive &Ar, class UPackageMap *Map, bool &bOutSuccess)
Definition Vector.h:1195
T XYZ[3]
Definition Vector.h:72
static bool PointsAreSame(const TVector< T > &P, const TVector< T > &Q)
Definition Vector.h:1368
UE_FORCEINLINE_HINT UE::Math::TRotator< T > Rotation() const
Definition Vector.h:834
T Z
Definition Vector.h:68
TVector< T > BoundToCube(T Radius) const
Definition Vector.h:1861
void AddBounded(const TVector< T > &V, T Radius=MAX_int16)
Definition Vector.h:1946
UE_FORCEINLINE_HINT bool operator==(const TVector< T > &V) const
Definition Vector.h:1589
T CosineAngle2D(TVector< T > B) const
Definition Vector.h:2104
bool SerializeFromMismatchedTag(FName StructTag, FStructuredArchive::FSlot Slot)
Definition Vector.h:1177
TVector< T > GetUnsafeNormal() const
Definition Vector.h:1841
static UE_FORCEINLINE_HINT T DistSquared2D(const TVector< T > &V1, const TVector< T > &V2)
Definition Vector.h:1053
static TVector< T > Zero()
Definition Vector.h:112
TVector(T InX, T InY, T InZ)
Definition Vector.h:1487
T Y
Definition Vector.h:65
static CORE_API const TVector< T > ZeroVector
Definition Vector.h:79
static CORE_API const TVector< T > ZAxisVector
Definition Vector.h:109
T Length() const
Definition Vector.h:1722
static CORE_API const TVector< T > XAxisVector
Definition Vector.h:103
static T EvaluateBezier(const TVector< T > *ControlPoints, int32 NumPoints, TArray< TVector< T > > &OutPoints)
Definition Vector.h:2195
static TVector< T > UnitY()
Definition Vector.h:121
T operator[](int32 Index) const
Definition Vector.h:1659
T GetMin() const
Definition Vector.h:1686
TVector< T > GetClampedToSize2D(T Min, T Max) const
Definition Vector.h:1895
static CORE_API const TVector< T > BackwardVector
Definition Vector.h:94
bool IsNormalized() const
Definition Vector.h:1786
TVector< T > operator/(FArg Scale) const
Definition Vector.h:326
UE_FORCEINLINE_HINT TVector< T > operator+(const TVector< T > &V) const
Definition Vector.h:1565
static CORE_API const TVector< T > ForwardVector
Definition Vector.h:91
static TVector< T > UnitZ()
Definition Vector.h:124
static TVector< T > RadiansToDegrees(const TVector< T > &RadVector)
Definition Vector.h:1462
bool Serialize(FArchive &Ar)
Definition Vector.h:1165
TVector< T > RotateAngleAxisRad(const T AngleRad, const TVector< T > &Axis) const
Definition Vector.h:1341
bool IsZero() const
Definition Vector.h:1761
TVector< T > MirrorByPlane(const TPlane< T > &Plane) const
Definition Plane.h:613
TVector< T > GetUnsafeNormal2D() const
Definition Vector.h:1848
CORE_API TRotator< T > ToOrientationRotator() const
Definition UnrealMath.cpp:200
TVector< T > GetClampedToMaxSize2D(T MaxSize) const
Definition Vector.h:1926
UE_FORCEINLINE_HINT constexpr TVector(T InF, TVectorConstInit)
Definition Vector.h:1481
static CORE_API const TVector< T > OneVector
Definition Vector.h:82
UE_FORCEINLINE_HINT bool AllComponentsEqual(T Tolerance=UE_KINDA_SMALL_NUMBER) const
Definition Vector.h:1607
T GetComponentForAxis(EAxis::Type Axis) const
Definition Vector.h:1976
UE_FORCEINLINE_HINT TVector< T > operator+(FArg Bias) const
Definition Vector.h:302
static UE_FORCEINLINE_HINT T DotProduct(const TVector< T > &A, const TVector< T > &B)
Definition Vector.h:1559
void UnwindEuler()
Definition Vector.h:2272
static TVector< T > Max(const TVector< T > &A, const TVector< T > &B)
Definition Vector.h:2506
static CORE_API const TVector< T > UpVector
Definition Vector.h:85
UE_FORCEINLINE_HINT void DiagnosticCheckNaN() const
Definition Vector.h:147
FText ToCompactText() const
Definition Vector.h:2321
static UE_FORCEINLINE_HINT T DistXY(const TVector< T > &V1, const TVector< T > &V2)
Definition Vector.h:2472
TVector< T > ComponentMax(const TVector< T > &Other) const
Definition Vector.h:1704
static TVector< T > Min(const TVector< T > &A, const TVector< T > &B)
Definition Vector.h:2496
FString ToString() const
Definition Vector.h:2304
UE_FORCEINLINE_HINT TVector< T > Cross(const TVector< T > &V2) const
Definition Vector.h:1535
T GetMax() const
Definition Vector.h:1674
UE_FORCEINLINE_HINT TVector< T > operator*(FArg Scale) const
Definition Vector.h:314
T & Component(int32 Index)
Definition Vector.h:1952
TVector< T > GetClampedToMaxSize(T MaxSize) const
Definition Vector.h:1906
static UE_FORCEINLINE_HINT T Dist2D(const TVector< T > &V1, const TVector< T > &V2)
Definition Vector.h:1031
bool Normalize(T Tolerance=UE_SMALL_NUMBER)
Definition Vector.h:1767
TVector< T > operator/=(const TVector< T > &V)
Definition Vector.h:1645
TVector< T > operator+=(const TVector< T > &V)
Definition Vector.h:1621
static TVector< T > PointPlaneProject(const TVector< T > &Point, const TVector< T > &PlaneBase, const TVector< T > &PlaneNormal)
Definition Vector.h:1410
static CORE_API const TVector< T > LeftVector
Definition Vector.h:100
T GetAbsMax() const
Definition Vector.h:1680
TVector< T > GridSnap(const T &GridSz) const
Definition Vector.h:1855
static UE_FORCEINLINE_HINT T BoxPushOut(const TVector< T > &Normal, const TVector< T > &Size)
Definition Vector.h:2490
TVector(T InF)
Definition Vector.h:1474
T FReal
Definition Vector.h:55
bool Serialize(FStructuredArchive::FSlot Slot)
Definition Vector.h:1171
T GetAbsMin() const
Definition Vector.h:1692
static UE_FORCEINLINE_HINT T Distance(const TVector< T > &V1, const TVector< T > &V2)
Definition Vector.h:1018
T X
Definition Vector.h:62
TVector< T > operator-=(const TVector< T > &V)
Definition Vector.h:1629
TVector< T > GetSafeNormal(T Tolerance=UE_SMALL_NUMBER, const TVector< T > &ResultIfZero=ZeroVector) const
Definition Vector.h:2060
static void GenerateClusterCenters(TArray< TVector< T > > &Clusters, const TArray< TVector< T > > &Points, int32 NumIterations, int32 NumConnectionsToBeValid)
Definition Vector.h:2128
TVector< T > operator*=(const TVector< T > &V)
Definition Vector.h:1637
TVector< T > Projection() const
Definition Vector.h:1834
static UE_FORCEINLINE_HINT TVector< T > CrossProduct(const TVector< T > &A, const TVector< T > &B)
Definition Vector.h:1541
TVector(TIntPoint< IntType > A)
Definition Vector.h:1510
TVector< T > operator^(const TVector< T > &V) const
Definition Vector.h:1524
bool ContainsNaN() const
Definition Vector.h:2296
void ToDirectionAndLength(TVector< T > &OutDir, double &OutLength) const
Definition Vector.h:1792
TVector< T > Reciprocal() const
Definition Vector.h:2013
static bool Orthogonal(const TVector< T > &Normal1, const TVector< T > &Normal2, T OrthogonalCosineThreshold=UE_THRESH_NORMALS_ARE_ORTHOGONAL)
Definition Vector.h:1438
TVector< T > operator/=(FArg Scale)
Definition Vector.h:429
CORE_API TQuat< T > ToOrientationQuat() const
Definition UnrealMath.cpp:285
UE_FORCEINLINE_HINT T operator|(const TVector< T > &V) const
Definition Vector.h:1547
T Component(int32 Index) const
Definition Vector.h:1961
UE_FORCEINLINE_HINT bool Equals(const TVector< T > &V, T Tolerance=UE_KINDA_SMALL_NUMBER) const
Definition Vector.h:1601
TVector< T > MirrorByVector(const TVector< T > &MirrorNormal) const
Definition Vector.h:2054
static T Triple(const TVector< T > &X, const TVector< T > &Y, const TVector< T > &Z)
Definition Vector.h:1453
UE_FORCEINLINE_HINT bool operator!=(const TVector< T > &V) const
Definition Vector.h:1595
FText ToText() const
Definition Vector.h:2310
UE_FORCEINLINE_HINT TVector< T > operator-() const
Definition Vector.h:1614
static TVector< T > Max3(const TVector< T > &A, const TVector< T > &B, const TVector< T > &C)
Definition Vector.h:2526
static CORE_API TVector< T > SlerpVectorToDirection(const TVector< T > &V, const TVector< T > &Direction, T Alpha)
Definition UnrealMath.cpp:225
TVector< T > GetClampedToSize(T Min, T Max) const
Definition Vector.h:1884
UE_FORCEINLINE_HINT TVector< T > operator-(FArg Bias) const
Definition Vector.h:290
bool IsNearlyZero(T Tolerance=UE_KINDA_SMALL_NUMBER) const
Definition Vector.h:1752
T SizeSquared2D() const
Definition Vector.h:1746
TVector(const TVector2< T > V, T InZ)
Definition Vector.h:1326
void SetComponentForAxis(EAxis::Type Axis, T Component)
Definition Vector.h:1993
static void CreateOrthonormalBasis(TVector< T > &XAxis, TVector< T > &YAxis, TVector< T > &ZAxis)
Definition Vector.h:2247
TVector< T > RotateAngleAxis(const T AngleDeg, const TVector< T > &Axis) const
Definition Vector.h:1335
UE_FORCEINLINE_HINT TVector< T > operator*(const TVector< T > &V) const
Definition Vector.h:1577
T SquaredLength() const
Definition Vector.h:1734
bool IsUniform(T Tolerance=UE_KINDA_SMALL_NUMBER) const
Definition Vector.h:2048
UE_FORCEINLINE_HINT TVector< T > ProjectOnTo(const TVector< T > &A) const
Definition Vector.h:2115
static CORE_API TVector< T > SlerpNormals(const TVector< T > &NormalA, const TVector< T > &NormalB, T Alpha)
Definition UnrealMath.cpp:242
FString ToCompactString() const
Definition Vector.h:2374
UE_FORCEINLINE_HINT void DiagnosticCheckNaN(const TCHAR *Message) const
Definition Vector.h:148
static T PointPlaneDist(const TVector< T > &Point, const TVector< T > &PlaneBase, const TVector< T > &PlaneNormal)
Definition Vector.h:1399
static TVector< T > PointPlaneProject(const TVector< T > &Point, const TPlane< T > &Plane)
Definition Plane.h:619
static TVector< T > VectorPlaneProject(const TVector< T > &V, const TVector< T > &PlaneNormal)
Definition Vector.h:1418
static bool Parallel(const TVector< T > &Normal1, const TVector< T > &Normal2, T ParallelCosineThreshold=UE_THRESH_NORMALS_ARE_PARALLEL)
Definition Vector.h:1424
void FindBestAxisVectors(TVector< T > &Axis1, TVector< T > &Axis2) const
Definition Vector.h:2280
T SizeSquared() const
Definition Vector.h:1728
TVector(const TVector< FArg > &From)
Definition Vector.h:1218
TVector< T > GetAbs() const
Definition Vector.h:1710
TVector< T > GetSafeNormal2D(T Tolerance=UE_SMALL_NUMBER, const TVector< T > &ResultIfZero=ZeroVector) const
Definition Vector.h:2078
void Set(T InX, T InY, T InZ)
Definition Vector.h:1665
TVector(EForceInit)
Definition Vector.h:1517
TVector< T > BoundToBox(const TVector< T > &Min, const TVector< T > &Max) const
Definition Vector.h:1872
TVector< T > GetSignVector() const
Definition Vector.h:1823
TVector(TIntVector3< IntType > InVector)
Definition Vector.h:1502
TVector(const FLinearColor &InColor)
Definition Vector.h:1494
T Size2D() const
Definition Vector.h:1740
bool IsValidIndex(int32 Index) const
Definition Vector.h:1970
static bool PointsAreNear(const TVector< T > &Point1, const TVector< T > &Point2, T Dist)
Definition Vector.h:1388
UE_FORCEINLINE_HINT bool IsUnit(T LengthSquaredTolerance=UE_KINDA_SMALL_NUMBER) const
Definition Vector.h:1780
static bool Coplanar(const TVector< T > &Base1, const TVector< T > &Normal1, const TVector< T > &Base2, const TVector< T > &Normal2, T ParallelCosineThreshold=UE_THRESH_NORMALS_ARE_PARALLEL)
Definition Vector.h:1445
static UE_FORCEINLINE_HINT T DistSquared(const TVector< T > &V1, const TVector< T > &V2)
Definition Vector.h:2478
static CORE_API const TVector< T > RightVector
Definition Vector.h:97
UE_FORCEINLINE_HINT TVector< T > operator/(const TVector< T > &V) const
Definition Vector.h:1583
T Size() const
Definition Vector.h:1716
static UE_FORCEINLINE_HINT T Dist(const TVector< T > &V1, const TVector< T > &V2)
Definition Vector.h:2466
static UE_FORCEINLINE_HINT T DistSquaredXY(const TVector< T > &V1, const TVector< T > &V2)
Definition Vector.h:2484
UE_FORCEINLINE_HINT T Dot(const TVector< T > &V) const
Definition Vector.h:1553
static CORE_API const TVector< T > YAxisVector
Definition Vector.h:106
T HeadingAngle() const
Definition Vector.h:2446
static TVector< T > Min3(const TVector< T > &A, const TVector< T > &B, const TVector< T > &C)
Definition Vector.h:2516
static bool Coincident(const TVector< T > &Normal1, const TVector< T > &Normal2, T ParallelCosineThreshold=UE_THRESH_NORMALS_ARE_PARALLEL)
Definition Vector.h:1431
Definition UnrealMathFPU.h:42