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#pragma once
3
4#include "Chaos/Real.h"
5#include "Chaos/Array.h"
6#include "Chaos/Pair.h"
7
9
10#include <initializer_list>
11
12#if !COMPILE_WITHOUT_UNREAL_SUPPORT
13#include "Math/Vector.h"
14#include "Math/Vector2D.h"
15#include "Math/Vector4.h"
16#else
17#include <cmath>
18#include <iostream>
19#include <utility>
20#include <limits>
21namespace FMath
22{
23 float Sqrt(float v) { return sqrt(v); }
24 double Sqrt(double v) { return sqrt(v); }
25 float Atan2(float x, float y) { return atan2(x, y); }
26 double Atan2(double x, double y) { return atan2(x, y); }
27}
28#endif
29
30namespace Chaos
31{
32 template<class T, int d>
34 {
35 static const bool RequireRangeCheck = true;
36 };
37
38
39 template<class T, int d>
40 class TVector
41 {
42 public:
43 using FElement = T;
44 static const int NumElements = d;
46
47 TVector(const TVector&) = default;
48 TVector& operator=(const TVector&) = default;
49
50 TVector() = default;
51
52 explicit TVector(const FElement& Element)
53 {
54 for (int32 i = 0; i < NumElements; ++i)
55 {
56 V[i] = Element;
57 }
58 }
59
60 TVector(std::initializer_list<T> InElements)
61 {
62 check(InElements.size() == NumElements);
63 FElement* Element = &V[0];
64 for (auto InIt = InElements.begin(); InIt != InElements.end(); ++InIt)
65 {
66 *Element++ = *InIt;
67 }
68 }
69
71 TVector(const T& V0, const T& V1)
72 {
73 V[0] = V0;
74 V[1] = V1;
75 }
76
78 TVector(const T& V0, const T& V1, const T& V2)
79 {
80 V[0] = V0;
81 V[1] = V1;
82 V[2] = V2; //-V557
83 }
84
86 TVector(const T& V0, const T& V1, const T& V2, const T& V3)
87 {
88 V[0] = V0;
89 V[1] = V1;
90 V[2] = V2; //-V557
91 V[3] = V3; //-V557
92 }
93
94#if !COMPILE_WITHOUT_UNREAL_SUPPORT
96 TVector(const FVector3f& Other) // LWC_TODO: Make this explicit for FReal = double
97 {
98 V[0] = static_cast<FElement>(Other.X);
99 V[1] = static_cast<FElement>(Other.Y);
100 V[2] = static_cast<FElement>(Other.Z); //-V557
101 }
104 {
105 V[0] = static_cast<FElement>(Other.X);
106 V[1] = static_cast<FElement>(Other.Y);
107 V[2] = static_cast<FElement>(Other.Z); //-V557
108 }
109#endif
110
111 template<class T2>
113 {
114 for (int32 i = 0; i < NumElements; ++i)
115 {
116 V[i] = static_cast<T>(Other[i]);
117 }
118 }
119
120 template<class T2>
122 {
123 for (int32 i = 0; i < NumElements; ++i)
124 {
125 (*this)[i] = Other[i];
126 }
127 return *this;
128 }
129
131 {
133 {
134 check(Index >= 0);
136 }
137 return V[Index];
138 }
139
140 const FElement& operator[](int Index) const
141 {
143 {
144 check(Index >= 0);
146 }
147 return V[Index];
148 }
149
150 int32 Num() const
151 {
152 return NumElements;
153 }
154
155#if COMPILE_WITHOUT_UNREAL_SUPPORT
156 TVector(std::istream& Stream)
157 {
158 for (int32 i = 0; i < NumElements; ++i)
159 {
160 Stream.read(reinterpret_cast<char*>(&V[i]), sizeof(FElement));
161 }
162 }
163 void Write(std::ostream& Stream) const
164 {
165 for (int32 i = 0; i < NumElements; ++i)
166 {
167 Stream.write(reinterpret_cast<const char*>(&V[i]), sizeof(FElement));
168 }
169 }
170#endif
171 friend bool operator==(const TVector<T, d>& L, const TVector<T, d>& R)
172 {
173 for (int32 i = 0; i < NumElements; ++i)
174 {
175 if (L.V[i] != R.V[i])
176 {
177 return false;
178 }
179 }
180 return true;
181 }
182
183 friend bool operator!=(const TVector<T, d>& L, const TVector<T, d>& R)
184 {
185 return !(L == R);
186 }
187
188 bool ContainsNaN() const
189 {
190 for (int32 i = 0; i < NumElements; ++i)
191 {
192 if (!FMath::IsFinite(V[i]))
193 {
194 return true;
195 }
196 }
197
198 return false;
199 }
200
201
202 // @todo(ccaulfield): the following should only be available for TVector of numeric types
203// T Size() const
204// {
205// T SquaredSum = 0;
206// for (int32 i = 0; i < NumElements; ++i)
207// {
208// SquaredSum += ((*this)[i] * (*this)[i]);
209// }
210// return FMath::Sqrt(SquaredSum);
211// }
212// T Product() const
213// {
214// T Result = 1;
215// for (int32 i = 0; i < NumElements; ++i)
216// {
217// Result *= (*this)[i];
218// }
219// return Result;
220// }
221// static TVector<T, d> AxisVector(const int32 Axis)
222// {
223// check(Axis >= 0 && Axis < NumElements);
224// TVector<T, d> Result(0);
225// Result[Axis] = (T)1;
226// return Result;
227// }
228// T SizeSquared() const
229// {
230// T Result = 0;
231// for (int32 i = 0; i < d; ++i)
232// {
233// Result += ((*this)[i] * (*this)[i]);
234// }
235// return Result;
236// }
237// TVector<T, d> GetSafeNormal() const
238// {
239// //We want N / ||N|| and to avoid inf
240// //So we want N / ||N|| < 1 / eps => N eps < ||N||, but this is clearly true for all eps < 1 and N > 0
241// T SizeSqr = SizeSquared();
242// if (SizeSqr <= TNumericLimits<T>::Min())
243// return AxisVector(0);
244// return (*this) / FMath::Sqrt(SizeSqr);
245// }
246// T SafeNormalize()
247// {
248// T Size = SizeSquared();
249// if (Size < (T)1e-4)
250// {
251// *this = AxisVector(0);
252// return (T)0.;
253// }
254// Size = FMath::Sqrt(Size);
255// *this = (*this) / Size;
256// return Size;
257// }
258// TVector<T, d> operator-() const
259// {
260// TVector<T, d> Result;
261// for (int32 i = 0; i < Num; ++i)
262// {
263// Result[i] = -(*this)[i];
264// }
265// return Result;
266// }
267// TVector<T, d> operator*(const TVector<T, d>& Other) const
268// {
269// TVector<T, d> Result;
270// for (int32 i = 0; i < d; ++i)
271// {
272// Result[i] = (*this)[i] * Other[i];
273// }
274// return Result;
275// }
276// TVector<T, d> operator/(const TVector<T, d>& Other) const
277// {
278// TVector<T, d> Result;
279// for (int32 i = 0; i < d; ++i)
280// {
281// Result[i] = (*this)[i] / Other[i];
282// }
283// return Result;
284// }
285// TVector<T, d> operator+(const TVector<T, d>& Other) const
286// {
287// TVector<T, d> Result;
288// for (int32 i = 0; i < d; ++i)
289// {
290// Result[i] = (*this)[i] + Other[i];
291// }
292// return Result;
293// }
294// TVector<T, d> operator-(const TVector<T, d>& Other) const
295// {
296// TVector<T, d> Result;
297// for (int32 i = 0; i < d; ++i)
298// {
299// Result[i] = (*this)[i] - Other[i];
300// }
301// return Result;
302// }
303// TVector<T, d>& operator+=(const TVector<T, d>& Other)
304// {
305// for (int32 i = 0; i < d; ++i)
306// {
307// (*this)[i] += Other[i];
308// }
309// return *this;
310// }
311// TVector<T, d>& operator-=(const TVector<T, d>& Other)
312// {
313// for (int32 i = 0; i < d; ++i)
314// {
315// (*this)[i] -= Other[i];
316// }
317// return *this;
318// }
319// TVector<T, d>& operator/=(const TVector<T, d>& Other)
320// {
321// for (int32 i = 0; i < d; ++i)
322// {
323// (*this)[i] /= Other[i];
324// }
325// return *this;
326// }
327// TVector<T, d> operator*(const T& S) const
328// {
329// TVector<T, d> Result;
330// for (int32 i = 0; i < d; ++i)
331// {
332// Result[i] = (*this)[i] * S;
333// }
334// return Result;
335// }
336// friend TVector<T, d> operator*(const T S, const TVector<T, d>& V)
337// {
338// TVector<T, d> Ret;
339// for (int32 i = 0; i < d; ++i)
340// {
341// Ret[i] = S * V[i];
342// }
343// return Ret;
344// }
345// TVector<T, d>& operator*=(const T& S)
346// {
347// for (int32 i = 0; i < d; ++i)
348// {
349// (*this)[i] *= S;
350// }
351// return *this;
352// }
353// friend TVector<T, d> operator/(const T S, const TVector<T, d>& V)
354// {
355// TVector<T, d> Ret;
356// for (int32 i = 0; i < d; ++i)
357// {
358// Ret = S / V[i];
359// }
360// return Ret;
361// }
362//
363//#if COMPILE_WITHOUT_UNREAL_SUPPORT
364// static inline FReal DotProduct(const Vector<FReal, 3>& V1, const Vector<FReal, 3>& V2)
365// {
366// return V1[0] * V2[0] + V1[1] * V2[1] + V1[2] * V2[2];
367// }
368// static inline Vector<FReal, 3> CrossProduct(const Vector<FReal, 3>& V1, const Vector<FReal, 3>& V2)
369// {
370// Vector<FReal, 3> Result;
371// Result[0] = V1[1] * V2[2] - V1[2] * V2[1];
372// Result[1] = V1[2] * V2[0] - V1[0] * V2[2];
373// Result[2] = V1[0] * V2[1] - V1[1] * V2[0];
374// return Result;
375// }
376//#endif
377
378 private:
380 };
381
382
383#if !COMPILE_WITHOUT_UNREAL_SUPPORT
384 template<>
385 class TVector<FReal, 4> : public UE::Math::TVector4<FReal>
386 {
387 public:
390 using BaseType::X;
391 using BaseType::Y;
392 using BaseType::Z;
393 using BaseType::W;
394
395 TVector() = default;
396
397 explicit TVector(const FReal x)
398 : BaseType(x, x, x, x) {}
399 TVector(const FReal x, const FReal y, const FReal z, const FReal w)
400 : BaseType(x, y, z, w) {}
402 : BaseType(vec) {}
403 };
404
405 template<>
406 class TVector<FRealSingle, 3> : public UE::Math::TVector<FRealSingle>
407 {
408 public:
413
414 TVector() = default;
415
416 explicit TVector(const FRealSingle x)
417 : UE::Math::TVector<FRealSingle>(x, x, x) {}
418 TVector(const FRealSingle x, const FRealSingle y, const FRealSingle z)
419 : UE::Math::TVector<FRealSingle>(x, y, z) {}
422 TVector(const UE::Math::TVector<FRealDouble>& vec) // LWC_TODO: Precision loss. Make explicit for FRealSingle = FRealSingle?
423 : UE::Math::TVector<FRealSingle>((UE::Math::TVector<FRealSingle>)vec) {}
426 TVector(const UE::Math::TVector4<FRealDouble>& vec) // LWC_TODO: Precision loss. Make explicit for FRealSingle = FRealSingle?
427 : UE::Math::TVector<FRealSingle>((UE::Math::TVector4<FRealSingle>)vec) {}
428
429#if COMPILE_WITHOUT_UNREAL_SUPPORT
430 TVector(std::istream& Stream)
431 {
432 Stream.read(reinterpret_cast<char*>(&X), sizeof(X));
433 Stream.read(reinterpret_cast<char*>(&Y), sizeof(Y));
434 Stream.read(reinterpret_cast<char*>(&Z), sizeof(Z));
435 }
436 //operator UE::Math::TVector<FRealDouble>() const { return UE::Math::TVector<FRealDouble>((FRealDouble)X, (FRealDouble)Y, (FRealDouble)Z); }
437 void Write(std::ostream& Stream) const
438 {
439 Stream.write(reinterpret_cast<const char*>(&X), sizeof(X));
440 Stream.write(reinterpret_cast<const char*>(&Y), sizeof(Y));
441 Stream.write(reinterpret_cast<const char*>(&Z), sizeof(Z));
442 }
443#endif
444 static inline TVector<FRealSingle, 3> Lerp(const TVector<FRealSingle, 3>& V1, const TVector<FRealSingle, 3>& V2, const FRealSingle F) { return FMath::Lerp<UE::Math::TVector<FRealSingle>, FRealSingle>(V1, V2, F); }
448 {
449 return X <= V.X && Y <= V.Y && Z <= V.Z;
450 }
452 {
453 return X >= V.X && Y >= V.Y && Z >= V.Z;
454 }
456 {
457 return TVector<FRealSingle, 3>(-X, -Y, -Z);
458 }
476 {
477 return TVector<FRealSingle, 3>(S / V.X, S / V.Y, S / V.Z);
478 }
495 template<class T2>
497 {
498 return TVector<FRealSingle, 3>(X + static_cast<FRealSingle>(Other[0]), Y + static_cast<FRealSingle>(Other[1]), Z + static_cast<FRealSingle>(Other[2]));
499 }
500 template<class T2>
502 {
503 return TVector<FRealSingle, 3>(X - static_cast<FRealSingle>(Other[0]), Y - static_cast<FRealSingle>(Other[1]), Z - static_cast<FRealSingle>(Other[2]));
504 }
505 template<class T2>
507 {
508 return TVector<FRealSingle, 3>(X * static_cast<FRealSingle>(Other[0]), Y * static_cast<FRealSingle>(Other[1]), Z * static_cast<FRealSingle>(Other[2]));
509 }
510 template<class T2>
512 {
513 return TVector<FRealSingle, 3>(X / static_cast<FRealSingle>(Other[0]), Y / static_cast<FRealSingle>(Other[1]), Z / static_cast<FRealSingle>(Other[2]));
514 }
516 {
517 return X * Y * Z;
518 }
520 {
521 return (X > Y && X > Z) ? X : (Y > Z ? Y : Z);
522 }
524 {
525 return (X < Y && X < Z) ? X : (Y < Z ? Y : Z);
526 }
528 {
529 return (X > Y && X > Z) ? 0 : (Y > Z ? 1 : 2);
530 }
532 {
533 return (X == Y || !((Y < X) ^ (X < Z))) ? X : !((X < Y) ^ (Y < Z)) ? Y : Z;
534 }
535 TVector<FRealSingle, 3> ComponentwiseMin(const TVector<FRealSingle, 3>& Other) const { return {FMath::Min(X,Other.X), FMath::Min(Y,Other.Y), FMath::Min(Z,Other.Z)}; }
536 TVector<FRealSingle, 3> ComponentwiseMax(const TVector<FRealSingle, 3>& Other) const { return {FMath::Max(X,Other.X), FMath::Max(Y,Other.Y), FMath::Max(Z,Other.Z)}; }
538 {
539 return TVector<FRealSingle, 3>(V1.X > V2.X ? V1.X : V2.X, V1.Y > V2.Y ? V1.Y : V2.Y, V1.Z > V2.Z ? V1.Z : V2.Z);
540 }
541 inline void FlushToZero(FRealSingle Epsilon)
542 {
543 if ((X >= -Epsilon) && (X <= Epsilon)) { X = 0.0f; }
544 if ((Y >= -Epsilon) && (Y <= Epsilon)) { Y = 0.0f; }
545 if ((Z >= -Epsilon) && (Z <= Epsilon)) { Z = 0.0f; }
546 }
548 { return Axis == 0 ? TVector<FRealSingle, 3>(1.f, 0.f, 0.f) : (Axis == 1 ? TVector<FRealSingle, 3>(0.f, 1.f, 0.f) : TVector<FRealSingle, 3>(0.f, 0.f, 1.f)); }
550 {
551 const TVector<FRealSingle, 3> max = Max(V1, V2);
552 if (max.X > max.Y)
553 {
554 if (max.X > max.Z)
555 return MakePair(max.X, 0);
556 else
557 return MakePair(max.Z, 2);
558 }
559 else
560 {
561 if (max.Y > max.Z)
562 return MakePair(max.Y, 1);
563 else
564 return MakePair(max.Z, 2);
565 }
566 }
568 {
569 FRealSingle Size = SizeSquared();
570 if (Size < Epsilon)
571 {
572 *this = AxisVector(0);
573 return 0.f;
574 }
575 Size = FMath::Sqrt(Size);
576 *this = (*this) / Size;
577 return Size;
578 }
580 {
581 TVector<FRealSingle, 3> AbsVector(FMath::Abs(X), FMath::Abs(Y), FMath::Abs(Z));
582 if ((AbsVector.X <= AbsVector.Y) && (AbsVector.X <= AbsVector.Z))
583 {
584 // X is the smallest component
585 return TVector<FRealSingle, 3>(0, Z, -Y);
586 }
587 if ((AbsVector.Z <= AbsVector.X) && (AbsVector.Z <= AbsVector.Y))
588 {
589 // Z is the smallest component
590 return TVector<FRealSingle, 3>(Y, -X, 0);
591 }
592 // Y is the smallest component
593 return TVector<FRealSingle, 3>(-Z, 0, X);
594 }
596 {
597 FRealSingle s = CrossProduct(V1, V2).Size();
598 FRealSingle c = DotProduct(V1, V2);
599 return FMath::Atan2(s, c);
600 }
603 {
604 return (P1 - P0) / Dt;
605 }
606
608 {
609 return (B - A).IsNearlyZero(Epsilon);
610 }
611 };
612
613
614 template<>
615 class TVector<FRealDouble, 3> : public UE::Math::TVector<FRealDouble>
616 {
617 public:
622
623 TVector() = default;
624
625 explicit TVector(const FRealDouble x)
626 : UE::Math::TVector<FRealDouble>(x, x, x) {}
627 TVector(const FRealDouble x, const FRealDouble y, const FRealDouble z)
628 : UE::Math::TVector<FRealDouble>(x, y, z) {}
631 TVector(const UE::Math::TVector<FRealDouble>& vec) // LWC_TODO: Precision loss. Make explicit for FRealDouble = FRealSingle?
632 : UE::Math::TVector<FRealDouble>((UE::Math::TVector<FRealDouble>)vec) {}
634 : UE::Math::TVector<FRealDouble>(vec.X, vec.Y, vec.Z) {}
635#if COMPILE_WITHOUT_UNREAL_SUPPORT
636 TVector(std::istream& Stream)
637 {
638 Stream.read(reinterpret_cast<char*>(&X), sizeof(X));
639 Stream.read(reinterpret_cast<char*>(&Y), sizeof(Y));
640 Stream.read(reinterpret_cast<char*>(&Z), sizeof(Z));
641 }
642 //operator UE::Math::TVector<FRealDouble>() const { return UE::Math::TVector<FRealDouble>((FRealDouble)X, (FRealDouble)Y, (FRealDouble)Z); }
643 void Write(std::ostream& Stream) const
644 {
645 Stream.write(reinterpret_cast<const char*>(&X), sizeof(X));
646 Stream.write(reinterpret_cast<const char*>(&Y), sizeof(Y));
647 Stream.write(reinterpret_cast<const char*>(&Z), sizeof(Z));
648 }
649#endif
650 static inline TVector<FRealDouble, 3> Lerp(const TVector<FRealDouble, 3>& V1, const TVector<FRealDouble, 3>& V2, const FRealDouble F) { return FMath::Lerp<UE::Math::TVector<FRealDouble>, FRealDouble>(V1, V2, F); }
654 {
655 return X <= V.X && Y <= V.Y && Z <= V.Z;
656 }
658 {
659 return X >= V.X && Y >= V.Y && Z >= V.Z;
660 }
662 {
663 return TVector<FRealDouble, 3>(-X, -Y, -Z);
664 }
682 {
683 return TVector<FRealDouble, 3>(S / V.X, S / V.Y, S / V.Z);
684 }
701 template<class T2>
703 {
704 return TVector<FRealDouble, 3>(X + static_cast<FRealDouble>(Other[0]), Y + static_cast<FRealDouble>(Other[1]), Z + static_cast<FRealDouble>(Other[2]));
705 }
706 template<class T2>
708 {
709 return TVector<FRealDouble, 3>(X - static_cast<FRealDouble>(Other[0]), Y - static_cast<FRealDouble>(Other[1]), Z - static_cast<FRealDouble>(Other[2]));
710 }
711 template<class T2>
713 {
714 return TVector<FRealDouble, 3>(X * static_cast<FRealDouble>(Other[0]), Y * static_cast<FRealDouble>(Other[1]), Z * static_cast<FRealDouble>(Other[2]));
715 }
716 template<class T2>
718 {
719 return TVector<FRealDouble, 3>(X / static_cast<FRealDouble>(Other[0]), Y / static_cast<FRealDouble>(Other[1]), Z / static_cast<FRealDouble>(Other[2]));
720 }
722 {
723 return X * Y * Z;
724 }
726 {
727 return (X > Y && X > Z) ? X : (Y > Z ? Y : Z);
728 }
730 {
731 return (X < Y&& X < Z) ? X : (Y < Z ? Y : Z);
732 }
734 {
735 return (X > Y && X > Z) ? 0 : (Y > Z ? 1 : 2);
736 }
738 {
739 return (X == Y || !((Y < X) ^ (X < Z))) ? X : !((X < Y) ^ (Y < Z)) ? Y : Z;
740 }
741 TVector<FRealDouble, 3> ComponentwiseMin(const TVector<FRealDouble, 3>& Other) const { return { FMath::Min(X,Other.X), FMath::Min(Y,Other.Y), FMath::Min(Z,Other.Z) }; }
742 TVector<FRealDouble, 3> ComponentwiseMax(const TVector<FRealDouble, 3>& Other) const { return { FMath::Max(X,Other.X), FMath::Max(Y,Other.Y), FMath::Max(Z,Other.Z) }; }
744 {
745 return TVector<FRealDouble, 3>(V1.X > V2.X ? V1.X : V2.X, V1.Y > V2.Y ? V1.Y : V2.Y, V1.Z > V2.Z ? V1.Z : V2.Z);
746 }
747 inline void FlushToZero(FRealDouble Epsilon)
748 {
749 if ((X >= -Epsilon) && (X <= Epsilon)) { X = 0.0; }
750 if ((Y >= -Epsilon) && (Y <= Epsilon)) { Y = 0.0; }
751 if ((Z >= -Epsilon) && (Z <= Epsilon)) { Z = 0.0; }
752 }
754 {
755 return Axis == 0 ? TVector<FRealDouble, 3>(1.f, 0.f, 0.f) : (Axis == 1 ? TVector<FRealDouble, 3>(0.f, 1.f, 0.f) : TVector<FRealDouble, 3>(0.f, 0.f, 1.f));
756 }
758 {
759 const TVector<FRealDouble, 3> max = Max(V1, V2);
760 if (max.X > max.Y)
761 {
762 if (max.X > max.Z)
763 return MakePair(max.X, 0);
764 else
765 return MakePair(max.Z, 2);
766 }
767 else
768 {
769 if (max.Y > max.Z)
770 return MakePair(max.Y, 1);
771 else
772 return MakePair(max.Z, 2);
773 }
774 }
776 {
777 FRealDouble Size = SizeSquared();
778 if (Size < Epsilon)
779 {
780 *this = AxisVector(0);
781 return 0.f;
782 }
783 Size = FMath::Sqrt(Size);
784 *this = (*this) / Size;
785 return Size;
786 }
788 {
789 TVector<FRealDouble, 3> AbsVector(FMath::Abs(X), FMath::Abs(Y), FMath::Abs(Z));
790 if ((AbsVector.X <= AbsVector.Y) && (AbsVector.X <= AbsVector.Z))
791 {
792 // X is the smallest component
793 return TVector<FRealDouble, 3>(0, Z, -Y);
794 }
795 if ((AbsVector.Z <= AbsVector.X) && (AbsVector.Z <= AbsVector.Y))
796 {
797 // Z is the smallest component
798 return TVector<FRealDouble, 3>(Y, -X, 0);
799 }
800 // Y is the smallest component
801 return TVector<FRealDouble, 3>(-Z, 0, X);
802 }
804 {
805 FRealDouble s = CrossProduct(V1, V2).Size();
806 FRealDouble c = DotProduct(V1, V2);
807 return FMath::Atan2(s, c);
808 }
811 {
812 return (P1 - P0) / Dt;
813 }
814
816 {
817 return (B - A).IsNearlyZero(Epsilon);
818 }
819 };
820
821 template<>
822 class TVector<FRealSingle, 2> : public FVector2f
823 {
824 public:
825 using FElement = decltype(FVector2f::X);
826 using FVector2f::X;
827 using FVector2f::Y;
828
829 TVector() = default;
830
832 : FVector2f((decltype(FVector2f::X))x, (decltype(FVector2f::X))x) {} // LWC_TODO: Remove casts once FVector2f supports variants
836 : FVector2f(vec) {}
837#if COMPILE_WITHOUT_UNREAL_SUPPORT
838 TVector(std::istream& Stream)
839 {
840 Stream.read(reinterpret_cast<char*>(&X), sizeof(X));
841 Stream.read(reinterpret_cast<char*>(&Y), sizeof(Y));
842 }
843#endif
844 template <typename OtherT>
846 {
847 X = ((decltype(X))InVector[0]); // LWC_TODO: Remove casts once FVector2f supports variants
848 Y = ((decltype(Y))InVector[1]);
849 }
850#if COMPILE_WITHOUT_UNREAL_SUPPORT
851 void Write(std::ostream& Stream) const
852 {
853 Stream.write(reinterpret_cast<const char*>(&X), sizeof(X));
854 Stream.write(reinterpret_cast<const char*>(&Y), sizeof(Y));
855 }
856#endif
858 {
859 check(Axis >= 0 && Axis <= 1);
860 return Axis == 0 ? TVector<FRealSingle, 2>(1.f, 0.f) : TVector<FRealSingle, 2>(0.f, 1.f);
861 }
863 {
864 return X * Y;
865 }
867 {
868 return X > Y ? X : Y;
869 }
871 {
872 return X < Y ? X : Y;
873 }
875 {
876 return TVector<FRealSingle, 2>(V1.X > V2.X ? V1.X : V2.X, V1.Y > V2.Y ? V1.Y : V2.Y);
877 }
879 {
880 const TVector<FRealSingle, 2> max = Max(V1, V2);
881 if (max.X > max.Y)
882 {
883 return MakePair((FRealSingle)max.X, 0);
884 }
885 else
886 {
887 return MakePair((FRealSingle)max.Y, 1);
888 }
889 }
890 template<class T2>
892 {
893 return TVector<FRealSingle, 2>(X / static_cast<FRealSingle>(Other[0]), Y / static_cast<FRealSingle>(Other[1]));
894 }
907 };
908
909 template<>
910 class TVector<FRealDouble, 2> : public FVector2d
911 {
912 public:
913 using FElement = decltype(FVector2d::X);
914 using FVector2d::X;
915 using FVector2d::Y;
916
917 TVector() = default;
918
920 : FVector2d((decltype(FVector2d::X))x, (decltype(FVector2d::X))x) {} // LWC_TODO: Remove casts once FVector2d supports variants
924 : FVector2d(vec) {}
925#if COMPILE_WITHOUT_UNREAL_SUPPORT
926 TVector(std::istream& Stream)
927 {
928 Stream.read(reinterpret_cast<char*>(&X), sizeof(X));
929 Stream.read(reinterpret_cast<char*>(&Y), sizeof(Y));
930 }
931#endif
932 template <typename OtherT>
934 {
935 X = ((decltype(X))InVector[0]); // LWC_TODO: Remove casts once FVector2d supports variants
936 Y = ((decltype(Y))InVector[1]);
937 }
938#if COMPILE_WITHOUT_UNREAL_SUPPORT
939 void Write(std::ostream& Stream) const
940 {
941 Stream.write(reinterpret_cast<const char*>(&X), sizeof(X));
942 Stream.write(reinterpret_cast<const char*>(&Y), sizeof(Y));
943 }
944#endif
946 {
947 check(Axis >= 0 && Axis <= 1);
948 return Axis == 0 ? TVector<FRealDouble, 2>(1.f, 0.f) : TVector<FRealDouble, 2>(0.f, 1.f);
949 }
951 {
952 return X * Y;
953 }
955 {
956 return X > Y ? X : Y;
957 }
959 {
960 return X < Y ? X : Y;
961 }
963 {
964 return TVector<FRealDouble, 2>(V1.X > V2.X ? V1.X : V2.X, V1.Y > V2.Y ? V1.Y : V2.Y);
965 }
967 {
968 const TVector<FRealDouble, 2> max = Max(V1, V2);
969 if (max.X > max.Y)
970 {
971 return MakePair((FRealDouble)max.X, 0);
972 }
973 else
974 {
975 return MakePair((FRealDouble)max.Y, 1);
976 }
977 }
978 template<class T2>
980 {
981 return TVector<FRealDouble, 2>(X / static_cast<FRealDouble>(Other[0]), Y / static_cast<FRealDouble>(Other[1]));
982 }
995 };
996#endif // !COMPILE_WITHOUT_UNREAL_SUPPORT
997
998 template<class T>
999 class TVector<T, 3>
1000 {
1001 public:
1002 using FElement = T;
1003
1005 TVector(const TVector&) = default;
1006 TVector& operator=(const TVector&) = default;
1008
1010
1012 : X(InX), Y(InX), Z(InX) {}
1014 : X(InX), Y(InY), Z(InZ) {}
1015
1016 FORCEINLINE int32 Num() const { return 3; }
1017 FORCEINLINE bool operator==(const TVector<T, 3>& Other) const { return X == Other.X && Y == Other.Y && Z == Other.Z; }
1018#if !COMPILE_WITHOUT_UNREAL_SUPPORT
1020 {
1021 X = static_cast<T>(Other.X);
1022 Y = static_cast<T>(Other.Y);
1023 Z = static_cast<T>(Other.Z);
1024 }
1025#endif
1026 template<class T2>
1028 : X(static_cast<T>(Other.X))
1029 , Y(static_cast<T>(Other.Y))
1030 , Z(static_cast<T>(Other.Z))
1031 {}
1032
1033#if COMPILE_WITHOUT_UNREAL_SUPPORT
1034 FORCEINLINE TVector(std::istream& Stream)
1035 {
1036 Stream.read(reinterpret_cast<char*>(&X), sizeof(T));
1037 Stream.read(reinterpret_cast<char*>(&Y), sizeof(T));
1038 Stream.read(reinterpret_cast<char*>(&Z), sizeof(T));
1039 }
1040 FORCEINLINE void Write(std::ostream& Stream) const
1041 {
1042 Stream.write(reinterpret_cast<const char*>(&X), sizeof(T));
1043 Stream.write(reinterpret_cast<const char*>(&Y), sizeof(T));
1044 Stream.write(reinterpret_cast<const char*>(&Z), sizeof(T));
1045 }
1046#endif
1047 template<class T2>
1049 {
1050 X = Other.X;
1051 Y = Other.Y;
1052 Z = Other.Z;
1053 return *this;
1054 }
1056 {
1057 const T SquaredSum = X * X + Y * Y + Z * Z;
1058 return FMath::Sqrt(SquaredSum);
1059 }
1060 FORCEINLINE T Product() const { return X * Y * Z; }
1062 {
1063 TVector<T, 3> Result(0);
1064 Result[Axis] = (T)1;
1065 return Result;
1066 }
1067 FORCEINLINE T SizeSquared() const { return X * X + Y * Y + Z * Z; }
1068
1069 FORCEINLINE T Min() const { return FMath::Min3(X, Y, Z); }
1070 FORCEINLINE T Max() const { return FMath::Max3(X, Y, Z); }
1071 T Mid() const
1072 {
1073 return (X == Y || !((Y < X) ^ (X < Z))) ? X : !((X < Y) ^ (Y < Z)) ? Y : Z;
1074 }
1075
1076 FORCEINLINE TVector<T, 3> ComponentwiseMin(const TVector<T, 3>& Other) const { return {FMath::Min(X,Other.X), FMath::Min(Y,Other.Y), FMath::Min(Z,Other.Z)}; }
1077 FORCEINLINE TVector<T, 3> ComponentwiseMax(const TVector<T, 3>& Other) const { return {FMath::Max(X,Other.X), FMath::Max(Y,Other.Y), FMath::Max(Z,Other.Z)}; }
1078
1080 {
1081 //We want N / ||N|| and to avoid inf
1082 //So we want N / ||N|| < 1 / eps => N eps < ||N||, but this is clearly true for all eps < 1 and N > 0
1083 T SizeSqr = SizeSquared();
1085 return AxisVector(0);
1086 return (*this) / FMath::Sqrt(SizeSqr);
1087 }
1089 {
1090 T Size = SizeSquared();
1091 if (Size < (T)1e-4)
1092 {
1093 *this = AxisVector(0);
1094 return (T)0.;
1095 }
1096 Size = FMath::Sqrt(Size);
1097 *this = (*this) / Size;
1098 return Size;
1099 }
1100
1102 {
1103 return !FMath::IsFinite(X) || !FMath::IsFinite(Y) || !FMath::IsFinite(Z);
1104 }
1105
1107 FORCEINLINE T operator[](int32 Idx) const { return XYZ[Idx]; }
1108 FORCEINLINE T& operator[](int32 Idx) { return XYZ[Idx]; }
1110
1111 FORCEINLINE TVector<T, 3> operator-() const { return {-X, -Y, -Z}; }
1112 FORCEINLINE TVector<T, 3> operator*(const TVector<T, 3>& Other) const { return {X * Other.X, Y * Other.Y, Z * Other.Z}; }
1113 FORCEINLINE TVector<T, 3> operator/(const TVector<T, 3>& Other) const { return {X / Other.X, Y / Other.Y, Z / Other.Z}; }
1114 FORCEINLINE TVector<T, 3> operator/(const T Scalar) const { return {X / Scalar, Y / Scalar, Z / Scalar}; }
1115 FORCEINLINE TVector<T, 3> operator+(const TVector<T, 3>& Other) const { return {X + Other.X, Y + Other.Y, Z + Other.Z}; }
1116 FORCEINLINE TVector<T, 3> operator+(const T Scalar) const { return {X + Scalar, Y + Scalar, Z + Scalar}; }
1117 FORCEINLINE TVector<T, 3> operator-(const TVector<T, 3>& Other) const { return {X - Other.X, Y - Other.Y, Z - Other.Z}; }
1118 FORCEINLINE TVector<T, 3> operator-(const T Scalar) const { return {X - Scalar, Y - Scalar, Z - Scalar}; }
1119
1121 {
1122 X += Other.X;
1123 Y += Other.Y;
1124 Z += Other.Z;
1125 return *this;
1126 }
1128 {
1129 X -= Other.X;
1130 Y -= Other.Y;
1131 Z -= Other.Z;
1132 return *this;
1133 }
1135 {
1136 X /= Other.X;
1137 Y /= Other.Y;
1138 Z /= Other.Z;
1139 return *this;
1140 }
1141 FORCEINLINE TVector<T, 3> operator*(const T S) const { return {X * S, Y * S, Z * S}; }
1143 {
1144 X *= S;
1145 Y *= S;
1146 Z *= S;
1147 return *this;
1148 }
1149#if COMPILE_WITHOUT_UNREAL_SUPPORT
1150 FORCEINLINE static inline FReal DotProduct(const Vector<FReal, 3>& V1, const Vector<FReal, 3>& V2)
1151 {
1152 return V1[0] * V2[0] + V1[1] * V2[1] + V1[2] * V2[2];
1153 }
1154 FORCEINLINE static inline Vector<FReal, 3> CrossProduct(const Vector<FReal, 3>& V1, const Vector<FReal, 3>& V2)
1155 {
1156 Vector<FReal, 3> Result;
1157 Result[0] = V1[1] * V2[2] - V1[2] * V2[1];
1158 Result[1] = V1[2] * V2[0] - V1[0] * V2[2];
1159 Result[2] = V1[0] * V2[1] - V1[1] * V2[0];
1160 return Result;
1161 }
1162#endif
1163
1164 union
1165 {
1166 struct
1167 {
1168 T X;
1169 T Y;
1170 T Z;
1171 };
1172
1173 UE_DEPRECATED(all, "For internal use only")
1174 T XYZ[3];
1175 };
1176 };
1177 template<class T>
1178 inline TVector<T, 3> operator*(const T S, const TVector<T, 3>& V)
1179 {
1180 return TVector<T, 3>{V.X * S, V.Y * S, V.Z * S};
1181 }
1182 template<class T>
1183 inline TVector<T, 3> operator/(const T S, const TVector<T, 3>& V)
1184 {
1185 return TVector<T, 3>{V.X / S, V.Y / S, V.Z / S};
1186 }
1187
1188 template<>
1189 class TVector<int32, 2>
1190 {
1191 public:
1193
1195 TVector(const TVector&) = default;
1196 TVector& operator=(const TVector&) = default;
1198
1200
1202 : X(InX), Y(InX)
1203 {}
1205 : X(InX), Y(InY)
1206 {}
1207 template<typename OtherT>
1209 : X((int32)InVector.X)
1210 , Y((int32)InVector.Y)
1211 {}
1212#if COMPILE_WITHOUT_UNREAL_SUPPORT
1213 FORCEINLINE TVector(std::istream& Stream)
1214 {
1215 Stream.read(reinterpret_cast<char*>(&X), sizeof(int32));
1216 Stream.read(reinterpret_cast<char*>(&Y), sizeof(int32));
1217 }
1218#endif
1219 FORCEINLINE int32 Num() const { return 2; }
1220
1222 {
1223 return X * Y;
1224 }
1225
1227 {
1228 TVector<FElement, 2> Result(0);
1229 Result[Axis] = 1;
1230 return Result;
1231 }
1232
1233#if COMPILE_WITHOUT_UNREAL_SUPPORT
1234 FORCEINLINE void Write(std::ostream& Stream) const
1235 {
1236 Stream.write(reinterpret_cast<const char*>(&X), sizeof(FElement));
1237 Stream.write(reinterpret_cast<const char*>(&Y), sizeof(FElement));
1238 }
1239#endif
1240
1241 template<typename OtherT>
1243 {
1244 X = Other.X;
1245 Y = Other.Y;
1246 return *this;
1247 }
1248
1250 FORCEINLINE FElement operator[](const int32 Idx) const { return XY[Idx]; }
1251 FORCEINLINE FElement& operator[](const int32 Idx) { return XY[Idx]; }
1253
1259
1261 {
1262 X += Other.X;
1263 Y += Other.Y;
1264 return *this;
1265 }
1267 {
1268 X -= Other.X;
1269 Y -= Other.Y;
1270 return *this;
1271 }
1273 {
1274 X /= Other.X;
1275 Y /= Other.Y;
1276 return *this;
1277 }
1279 {
1280 return {X * S, Y * S};
1281 }
1283 {
1284 X *= S;
1285 Y *= S;
1286 return *this;
1287 }
1288
1290 {
1291 return (L.X == R.X) && (L.Y == R.Y);
1292 }
1293
1295 {
1296 return !(L == R);
1297 }
1298
1299
1300 private:
1301 union
1302 {
1303 struct
1304 {
1307 };
1308
1309 UE_DEPRECATED(all, "For internal use only")
1311 };
1312 };
1313
1314 template<class T>
1316 {
1317 uint32 Seed = ::GetTypeHash(V[0]);
1318 Seed ^= ::GetTypeHash(V[1]) + 0x9e3779b9 + (Seed << 6) + (Seed >> 2);
1319 return Seed;
1320 }
1321
1322 template<class T>
1324 {
1325 uint32 Seed = ::GetTypeHash(V[0]);
1326 Seed ^= ::GetTypeHash(V[1]) + 0x9e3779b9 + (Seed << 6) + (Seed >> 2);
1327 Seed ^= ::GetTypeHash(V[2]) + 0x9e3779b9 + (Seed << 6) + (Seed >> 2);
1328 return Seed;
1329 }
1330
1331 // this is used as
1332 template<typename T, int d>
1334 {
1335 static_assert(std::is_same_v<T, float> || std::is_same_v<T, double>, "only float or double are supported by this function");
1336 for (int32 Idx = 0; Idx < d; ++Idx)
1337 {
1339 Ar << RealSingle;
1341 }
1342 return Ar;
1343 }
1344
1345 template<int d>
1350
1351 template<int d>
1356
1357 // general for for all other vectors
1358 template<typename T, int d>
1360 {
1361 // unchanged type code path
1362 for (int32 Idx = 0; Idx < d; ++Idx)
1363 {
1364 Ar << ValueIn[Idx];
1365 }
1366 return Ar;
1367 }
1368
1369} // namespace Chaos
1370
1371//template<>
1372//uint32 GetTypeHash(const Chaos::TVector<int32, 2>& V)
1373//{
1374// uint32 Seed = GetTypeHash(V[0]);
1375// Seed ^= GetTypeHash(V[1]) + 0x9e3779b9 + (Seed << 6) + (Seed >> 2);
1376// return Seed;
1377//}
1378
1379// LWC_TODO: UE::Math::TVector<FReal> construction from a chaos float vec3
1380//inline UE::Math::TVector<FReal>::UE::Math::TVector<FReal>(const Chaos::TVector<float, 3>& ChaosVector) : X(ChaosVector.X), Y(ChaosVector.Y), Z(ChaosVector.Z) {}
1381
#define FORCEINLINE
Definition AndroidPlatform.h:140
#define check(expr)
Definition AssertionMacros.h:314
#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 PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
uint32 Size
Definition VulkanMemory.cpp:4034
uint32_t uint32
Definition binka_ue_file_header.h:6
TVector< FRealDouble, 2 > operator*(const TVector< FRealDouble, 2 > &Other) const
Definition Vector.h:991
TVector(const FRealDouble x, const FRealDouble y)
Definition Vector.h:921
TVector(const TVector< OtherT, 2 > &InVector)
Definition Vector.h:933
TVector< FRealDouble, 2 > operator/(const FRealDouble Other) const
Definition Vector.h:983
static Pair< FRealDouble, int32 > MaxAndAxis(const TVector< FRealDouble, 2 > &V1, const TVector< FRealDouble, 2 > &V2)
Definition Vector.h:966
FRealDouble Max() const
Definition Vector.h:954
static TVector< FRealDouble, 2 > Max(const TVector< FRealDouble, 2 > &V1, const TVector< FRealDouble, 2 > &V2)
Definition Vector.h:962
FRealDouble Min() const
Definition Vector.h:958
TVector(const FVector2d &vec)
Definition Vector.h:923
FRealDouble Product() const
Definition Vector.h:950
decltype(FVector2d::X) FElement
Definition Vector.h:913
TVector(const FRealDouble x)
Definition Vector.h:919
static TVector< FRealDouble, 2 > AxisVector(const int32 Axis)
Definition Vector.h:945
TVector< FRealDouble, 2 > operator/(const TVector< T2, 2 > &Other) const
Definition Vector.h:979
TVector< FRealDouble, 2 > operator*(const FRealDouble Other) const
Definition Vector.h:987
TVector(const UE::Math::TVector< FRealSingle > &vec)
Definition Vector.h:629
bool operator>=(const TVector< FRealDouble, 3 > &V) const
Definition Vector.h:657
FRealDouble Min() const
Definition Vector.h:729
TVector< FRealDouble, 3 > GetOrthogonalVector() const
Definition Vector.h:787
bool operator<=(const TVector< FRealDouble, 3 > &V) const
Definition Vector.h:653
static bool IsNearlyEqual(const TVector< FRealDouble, 3 > &A, const TVector< FRealDouble, 3 > &B, const FRealDouble Epsilon)
Definition Vector.h:815
TVector< FRealDouble, 3 > operator*(const FRealDouble Other) const
Definition Vector.h:673
void FlushToZero(FRealDouble Epsilon)
Definition Vector.h:747
static TVector< FRealDouble, 3 > CalculateVelocity(const TVector< FRealDouble, 3 > &P0, const TVector< FRealDouble, 3 > &P1, const FRealDouble Dt)
Definition Vector.h:810
TVector< FRealDouble, 3 > ComponentwiseMax(const TVector< FRealDouble, 3 > &Other) const
Definition Vector.h:742
static TVector< FRealDouble, 3 > Lerp(const TVector< FRealDouble, 3 > &V1, const TVector< FRealDouble, 3 > &V2, const FRealDouble F)
Definition Vector.h:650
FRealDouble Mid() const
Definition Vector.h:737
TVector(const FVector4 &vec)
Definition Vector.h:633
TVector< FRealDouble, 3 > operator+(const FRealDouble Other) const
Definition Vector.h:665
FRealDouble Max() const
Definition Vector.h:725
TVector< FRealDouble, 3 > ComponentwiseMin(const TVector< FRealDouble, 3 > &Other) const
Definition Vector.h:741
FRealDouble Product() const
Definition Vector.h:721
static Pair< FRealDouble, int32 > MaxAndAxis(const TVector< FRealDouble, 3 > &V1, const TVector< FRealDouble, 3 > &V2)
Definition Vector.h:757
TVector< FRealDouble, 3 > operator-(const TVector< FRealDouble, 3 > &Other) const
Definition Vector.h:689
static FRealDouble DotProduct(const TVector< FRealDouble, 3 > &V1, const TVector< FRealDouble, 3 > &V2)
Definition Vector.h:652
FRealDouble FElement
Definition Vector.h:618
TVector< FRealDouble, 3 > operator*(const TVector< T2, 3 > &Other) const
Definition Vector.h:712
TVector< FRealDouble, 3 > operator-() const
Definition Vector.h:661
friend TVector< FRealDouble, 3 > operator/(const FRealDouble S, const TVector< FRealDouble, 3 > &V)
Definition Vector.h:681
TVector(const FRealDouble x)
Definition Vector.h:625
TVector(const FRealDouble x, const FRealDouble y, const FRealDouble z)
Definition Vector.h:627
TVector< FRealDouble, 3 > operator/(const TVector< T2, 3 > &Other) const
Definition Vector.h:717
static TVector< FRealDouble, 3 > Max(const TVector< FRealDouble, 3 > &V1, const TVector< FRealDouble, 3 > &V2)
Definition Vector.h:743
TVector< FRealDouble, 3 > operator/(const FRealDouble Other) const
Definition Vector.h:677
TVector< FRealDouble, 3 > operator-(const FRealDouble Other) const
Definition Vector.h:669
FRealDouble SafeNormalize(FRealDouble Epsilon=1e-4f)
Definition Vector.h:775
TVector< FRealDouble, 3 > operator-(const TVector< T2, 3 > &Other) const
Definition Vector.h:707
static TVector< FRealDouble, 3 > AxisVector(const int32 Axis)
Definition Vector.h:753
TVector< FRealDouble, 3 > operator/(const TVector< FRealDouble, 3 > &Other) const
Definition Vector.h:697
TVector< FRealDouble, 3 > operator+(const TVector< FRealDouble, 3 > &Other) const
Definition Vector.h:685
TVector(const UE::Math::TVector< FRealDouble > &vec)
Definition Vector.h:631
static FRealDouble AngleBetween(const TVector< FRealDouble, 3 > &V1, const TVector< FRealDouble, 3 > &V2)
Definition Vector.h:803
int32 MaxAxis() const
Definition Vector.h:733
TVector< FRealDouble, 3 > operator*(const TVector< FRealDouble, 3 > &Other) const
Definition Vector.h:693
TVector< FRealDouble, 3 > operator+(const TVector< T2, 3 > &Other) const
Definition Vector.h:702
static TVector< FRealDouble, 3 > CrossProduct(const TVector< FRealDouble, 3 > &V1, const TVector< FRealDouble, 3 > &V2)
Definition Vector.h:651
FRealSingle Product() const
Definition Vector.h:862
TVector(const TVector< OtherT, 2 > &InVector)
Definition Vector.h:845
static TVector< FRealSingle, 2 > AxisVector(const int32 Axis)
Definition Vector.h:857
TVector< FRealSingle, 2 > operator/(const TVector< T2, 2 > &Other) const
Definition Vector.h:891
FRealSingle Min() const
Definition Vector.h:870
TVector< FRealSingle, 2 > operator/(const FRealSingle Other) const
Definition Vector.h:895
TVector< FRealSingle, 2 > operator*(const FRealSingle Other) const
Definition Vector.h:899
decltype(FVector2f::X) FElement
Definition Vector.h:825
TVector(const FRealSingle x)
Definition Vector.h:831
TVector(const FVector2f &vec)
Definition Vector.h:835
static Pair< FRealSingle, int32 > MaxAndAxis(const TVector< FRealSingle, 2 > &V1, const TVector< FRealSingle, 2 > &V2)
Definition Vector.h:878
FRealSingle Max() const
Definition Vector.h:866
static TVector< FRealSingle, 2 > Max(const TVector< FRealSingle, 2 > &V1, const TVector< FRealSingle, 2 > &V2)
Definition Vector.h:874
TVector(const FRealSingle x, const FRealSingle y)
Definition Vector.h:833
TVector< FRealSingle, 2 > operator*(const TVector< FRealSingle, 2 > &Other) const
Definition Vector.h:903
TVector(const UE::Math::TVector4< FRealSingle > &vec)
Definition Vector.h:424
static TVector< FRealSingle, 3 > CalculateVelocity(const TVector< FRealSingle, 3 > &P0, const TVector< FRealSingle, 3 > &P1, const FRealSingle Dt)
Definition Vector.h:602
TVector< FRealSingle, 3 > operator-(const TVector< T2, 3 > &Other) const
Definition Vector.h:501
static FRealSingle DotProduct(const TVector< FRealSingle, 3 > &V1, const TVector< FRealSingle, 3 > &V2)
Definition Vector.h:446
FRealSingle Product() const
Definition Vector.h:515
FRealSingle Max() const
Definition Vector.h:519
TVector< FRealSingle, 3 > operator*(const TVector< T2, 3 > &Other) const
Definition Vector.h:506
TVector< FRealSingle, 3 > ComponentwiseMax(const TVector< FRealSingle, 3 > &Other) const
Definition Vector.h:536
friend TVector< FRealSingle, 3 > operator/(const FRealSingle S, const TVector< FRealSingle, 3 > &V)
Definition Vector.h:475
static TVector< FRealSingle, 3 > CrossProduct(const TVector< FRealSingle, 3 > &V1, const TVector< FRealSingle, 3 > &V2)
Definition Vector.h:445
static FRealSingle AngleBetween(const TVector< FRealSingle, 3 > &V1, const TVector< FRealSingle, 3 > &V2)
Definition Vector.h:595
TVector< FRealSingle, 3 > GetOrthogonalVector() const
Definition Vector.h:579
TVector< FRealSingle, 3 > operator/(const TVector< T2, 3 > &Other) const
Definition Vector.h:511
TVector< FRealSingle, 3 > operator/(const FRealSingle Other) const
Definition Vector.h:471
static bool IsNearlyEqual(const TVector< FRealSingle, 3 > &A, const TVector< FRealSingle, 3 > &B, const FRealSingle Epsilon)
Definition Vector.h:607
static TVector< FRealSingle, 3 > AxisVector(const int32 Axis)
Definition Vector.h:547
TVector< FRealSingle, 3 > operator-(const TVector< FRealSingle, 3 > &Other) const
Definition Vector.h:483
void FlushToZero(FRealSingle Epsilon)
Definition Vector.h:541
TVector< FRealSingle, 3 > operator*(const TVector< FRealSingle, 3 > &Other) const
Definition Vector.h:487
TVector(const FRealSingle x)
Definition Vector.h:416
FRealSingle FElement
Definition Vector.h:409
static TVector< FRealSingle, 3 > Max(const TVector< FRealSingle, 3 > &V1, const TVector< FRealSingle, 3 > &V2)
Definition Vector.h:537
bool operator<=(const TVector< FRealSingle, 3 > &V) const
Definition Vector.h:447
TVector< FRealSingle, 3 > operator+(const TVector< FRealSingle, 3 > &Other) const
Definition Vector.h:479
TVector< FRealSingle, 3 > operator-() const
Definition Vector.h:455
TVector< FRealSingle, 3 > operator+(const TVector< T2, 3 > &Other) const
Definition Vector.h:496
FRealSingle SafeNormalize(FRealSingle Epsilon=1e-4f)
Definition Vector.h:567
FRealSingle Min() const
Definition Vector.h:523
TVector< FRealSingle, 3 > ComponentwiseMin(const TVector< FRealSingle, 3 > &Other) const
Definition Vector.h:535
TVector(const FRealSingle x, const FRealSingle y, const FRealSingle z)
Definition Vector.h:418
static Pair< FRealSingle, int32 > MaxAndAxis(const TVector< FRealSingle, 3 > &V1, const TVector< FRealSingle, 3 > &V2)
Definition Vector.h:549
TVector< FRealSingle, 3 > operator+(const FRealSingle Other) const
Definition Vector.h:459
TVector< FRealSingle, 3 > operator-(const FRealSingle Other) const
Definition Vector.h:463
int32 MaxAxis() const
Definition Vector.h:527
TVector(const UE::Math::TVector< FRealDouble > &vec)
Definition Vector.h:422
bool operator>=(const TVector< FRealSingle, 3 > &V) const
Definition Vector.h:451
FRealSingle Mid() const
Definition Vector.h:531
TVector(const UE::Math::TVector< FRealSingle > &vec)
Definition Vector.h:420
TVector< FRealSingle, 3 > operator*(const FRealSingle Other) const
Definition Vector.h:467
TVector< FRealSingle, 3 > operator/(const TVector< FRealSingle, 3 > &Other) const
Definition Vector.h:491
TVector(const UE::Math::TVector4< FRealDouble > &vec)
Definition Vector.h:426
static TVector< FRealSingle, 3 > Lerp(const TVector< FRealSingle, 3 > &V1, const TVector< FRealSingle, 3 > &V2, const FRealSingle F)
Definition Vector.h:444
FReal FElement
Definition Vector.h:388
TVector(const FReal x)
Definition Vector.h:397
TVector(const FReal x, const FReal y, const FReal z, const FReal w)
Definition Vector.h:399
TVector(const BaseType &vec)
Definition Vector.h:401
FORCEINLINE TVector< T, 3 > & operator+=(const TVector< T, 3 > &Other)
Definition Vector.h:1120
FORCEINLINE TVector< T, 3 > ComponentwiseMax(const TVector< T, 3 > &Other) const
Definition Vector.h:1077
FORCEINLINE TVector< T, 3 > operator+(const TVector< T, 3 > &Other) const
Definition Vector.h:1115
T FElement
Definition Vector.h:1002
FORCEINLINE int32 Num() const
Definition Vector.h:1016
FORCEINLINE T Size() const
Definition Vector.h:1055
T X
Definition Vector.h:1168
FORCEINLINE TVector< T, 3 > operator-(const TVector< T, 3 > &Other) const
Definition Vector.h:1117
T Z
Definition Vector.h:1170
FORCEINLINE TVector< T, 3 > operator+(const T Scalar) const
Definition Vector.h:1116
FORCEINLINE T SafeNormalize()
Definition Vector.h:1088
FORCEINLINE TVector< T, 3 > operator-(const T Scalar) const
Definition Vector.h:1118
FORCEINLINE TVector< T, 3 > & operator*=(const T S)
Definition Vector.h:1142
TVector< T, 3 > GetSafeNormal() const
Definition Vector.h:1079
FORCEINLINE T Max() const
Definition Vector.h:1070
FORCEINLINE TVector< T, 3 > & operator-=(const TVector< T, 3 > &Other)
Definition Vector.h:1127
PRAGMA_ENABLE_DEPRECATION_WARNINGS FORCEINLINE TVector()=default
FORCEINLINE T Product() const
Definition Vector.h:1060
FORCEINLINE T Min() const
Definition Vector.h:1069
FORCEINLINE TVector(T InX)
Definition Vector.h:1011
FORCEINLINE TVector< T, 3 > operator/(const TVector< T, 3 > &Other) const
Definition Vector.h:1113
TVector & operator=(const TVector &)=default
FORCEINLINE TVector(T InX, T InY, T InZ)
Definition Vector.h:1013
PRAGMA_DISABLE_DEPRECATION_WARNINGS TVector(const TVector &)=default
PRAGMA_ENABLE_DEPRECATION_WARNINGS FORCEINLINE TVector< T, 3 > operator-() const
Definition Vector.h:1111
static FORCEINLINE TVector< T, 3 > AxisVector(const int32 Axis)
Definition Vector.h:1061
T Y
Definition Vector.h:1169
FORCEINLINE TVector< T, 3 > ComponentwiseMin(const TVector< T, 3 > &Other) const
Definition Vector.h:1076
FORCEINLINE bool operator==(const TVector< T, 3 > &Other) const
Definition Vector.h:1017
FORCEINLINE bool ContainsNaN() const
Definition Vector.h:1101
T Mid() const
Definition Vector.h:1071
FORCEINLINE TVector< T, 3 > operator*(const T S) const
Definition Vector.h:1141
FORCEINLINE T & operator[](int32 Idx)
Definition Vector.h:1108
FORCEINLINE TVector(const TVector< T2, 3 > &Other)
Definition Vector.h:1027
FORCEINLINE TVector< T, 3 > & operator=(const TVector< T2, 3 > &Other)
Definition Vector.h:1048
FORCEINLINE TVector< T, 3 > & operator/=(const TVector< T, 3 > &Other)
Definition Vector.h:1134
FORCEINLINE TVector(const UE::Math::TVector< FReal > &Other)
Definition Vector.h:1019
FORCEINLINE T SizeSquared() const
Definition Vector.h:1067
PRAGMA_DISABLE_DEPRECATION_WARNINGS FORCEINLINE T operator[](int32 Idx) const
Definition Vector.h:1107
FORCEINLINE TVector< T, 3 > operator*(const TVector< T, 3 > &Other) const
Definition Vector.h:1112
FORCEINLINE TVector< T, 3 > operator/(const T Scalar) const
Definition Vector.h:1114
FElement Y
Definition Vector.h:1306
FORCEINLINE TVector(const TVector< OtherT, 2 > &InVector)
Definition Vector.h:1208
PRAGMA_ENABLE_DEPRECATION_WARNINGS FORCEINLINE TVector< FElement, 2 > operator-() const
Definition Vector.h:1254
FORCEINLINE FElement & operator[](const int32 Idx)
Definition Vector.h:1251
PRAGMA_DISABLE_DEPRECATION_WARNINGS TVector(const TVector &)=default
FORCEINLINE TVector< FElement, 2 > operator*(const FElement &S) const
Definition Vector.h:1278
FORCEINLINE friend bool operator==(const TVector< FElement, 2 > &L, const TVector< FElement, 2 > &R)
Definition Vector.h:1289
FORCEINLINE TVector< FElement, 2 > operator*(const TVector< FElement, 2 > &Other) const
Definition Vector.h:1255
FORCEINLINE TVector< FElement, 2 > & operator-=(const TVector< FElement, 2 > &Other)
Definition Vector.h:1266
int32 FElement
Definition Vector.h:1192
FORCEINLINE TVector< FElement, 2 > & operator*=(const FElement &S)
Definition Vector.h:1282
PRAGMA_ENABLE_DEPRECATION_WARNINGS FORCEINLINE TVector()=default
PRAGMA_DISABLE_DEPRECATION_WARNINGS FORCEINLINE FElement operator[](const int32 Idx) const
Definition Vector.h:1250
static FORCEINLINE TVector< FElement, 2 > AxisVector(const int32 Axis)
Definition Vector.h:1226
FORCEINLINE TVector(const FElement InX)
Definition Vector.h:1201
FORCEINLINE TVector(const FElement InX, const FElement InY)
Definition Vector.h:1204
FORCEINLINE TVector< FElement, 2 > & operator/=(const TVector< FElement, 2 > &Other)
Definition Vector.h:1272
FORCEINLINE TVector< FElement, 2 > operator+(const TVector< FElement, 2 > &Other) const
Definition Vector.h:1257
FORCEINLINE TVector< FElement, 2 > & operator+=(const TVector< FElement, 2 > &Other)
Definition Vector.h:1260
FORCEINLINE TVector< FElement, 2 > operator-(const TVector< FElement, 2 > &Other) const
Definition Vector.h:1258
TVector & operator=(const TVector &)=default
FElement X
Definition Vector.h:1305
FORCEINLINE FElement Product() const
Definition Vector.h:1221
FORCEINLINE TVector< FElement, 2 > operator/(const TVector< FElement, 2 > &Other) const
Definition Vector.h:1256
FORCEINLINE int32 Num() const
Definition Vector.h:1219
FORCEINLINE friend bool operator!=(const TVector< FElement, 2 > &L, const TVector< FElement, 2 > &R)
Definition Vector.h:1294
FORCEINLINE TVector< int32, 2 > & operator=(const TVector< OtherT, 2 > &Other)
Definition Vector.h:1242
Definition Vector.h:41
TVector(const TVector< T2, d > &Other)
Definition Vector.h:112
const FElement & operator[](int Index) const
Definition Vector.h:140
static const int NumElements
Definition Vector.h:44
TVector(const TVector &)=default
bool ContainsNaN() const
Definition Vector.h:188
TVector & operator=(const TVector &)=default
TVector(const T &V0, const T &V1)
Definition Vector.h:71
TVector(const T &V0, const T &V1, const T &V2, const T &V3)
Definition Vector.h:86
TVector(const FElement &Element)
Definition Vector.h:52
TVector()=default
TVector(std::initializer_list< T > InElements)
Definition Vector.h:60
T FElement
Definition Vector.h:43
TVector< T, d > & operator=(const TVector< T2, d > &Other)
Definition Vector.h:121
friend bool operator==(const TVector< T, d > &L, const TVector< T, d > &R)
Definition Vector.h:171
int32 Num() const
Definition Vector.h:150
FElement & operator[](int Index)
Definition Vector.h:130
friend bool operator!=(const TVector< T, d > &L, const TVector< T, d > &R)
Definition Vector.h:183
TVector(const FVector3d &Other)
Definition Vector.h:103
TVector(const T &V0, const T &V1, const T &V2)
Definition Vector.h:78
TVector(const FVector3f &Other)
Definition Vector.h:96
Definition Archive.h:1208
Definition SkeletalMeshComponent.h:307
@ Y
Definition SimulationModuleBase.h:153
@ X
Definition SimulationModuleBase.h:152
FChaosArchive & operator<<(FChaosArchive &Ar, FRigidParticleControlFlags &Flags)
Definition RigidParticleControlFlags.cpp:15
FArchive & SerializeReal(FArchive &Ar, TVector< T, d > &ValueIn)
Definition Vector.h:1333
FRealDouble FReal
Definition Real.h:22
Pair< T1, T2 > MakePair(const T1 &First, const T2 &Second)
Definition Pair.h:45
float FRealSingle
Definition Real.h:14
double FRealDouble
Definition Real.h:13
FORCEINLINE uint32 GetTypeHash(const FParticleID &Unique)
Definition GeometryParticles.h:99
TVector< T, 3 > operator/(const T S, const TVector< T, 3 > &V)
Definition Vector.h:1183
FValue Atan2(const FValue &Lhs, const FValue &Rhs)
Definition ShaderValue.cpp:1564
Definition AdvancedWidgetsModule.cpp:13
float v
Definition radaudio_mdct.cpp:62
U16 Index
Definition radfft.cpp:71
Definition Pair.h:8
Definition Vector.h:34
static const bool RequireRangeCheck
Definition Vector.h:35
Definition UnrealMathUtility.h:270
static constexpr UE_FORCEINLINE_HINT T Min3(const T A, const T B, const T C)
Definition UnrealMathUtility.h:558
static constexpr UE_FORCEINLINE_HINT T Max3(const T A, const T B, const T C)
Definition UnrealMathUtility.h:551
Definition NumericLimits.h:41
float Y
Definition Vector2D.h:52
float X
Definition Vector2D.h:49
Definition Vector4.h:30
FReal FReal
Definition Vector4.h:36
static UE_FORCEINLINE_HINT T DotProduct(const TVector< T > &A, const TVector< T > &B)
Definition Vector.h:1559
static UE_FORCEINLINE_HINT TVector< T > CrossProduct(const TVector< T > &A, const TVector< T > &B)
Definition Vector.h:1541