UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VectorSetAnalysis.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "VectorTypes.h"
7
8namespace UE
9{
10namespace Geometry
11{
12
13using namespace UE::Math;
14
18template<typename RealType>
20{
21public:
22 //
23 // Input data
24 //
25
28 bool bNormalized = false;
29
30 //
31 // Calculated values
32 //
33
38
39
45 template<typename EnumerableIDType>
58
60 int32 NumVectors() const { return Vectors.Num(); }
61
63 int32 NumClusters() const { return ClusterVectors.Num(); }
64
65
72 {
73 check(bNormalized); // otherwise code below is incorrect
74
76
77 int32 N = NumVectors(), M = 0;
79 for (int32 k = 0; k < N; ++k)
80 {
81 bool bFound = false;
82 if (M > 0)
83 {
84 // try to find an existing cluster
85 for (int32 j = 0; j < M && !bFound; ++j)
86 {
88 {
89 VectorToClusterMap[k] = j;
90 bFound = true;
91 }
92 }
93 }
94
95 // cluster not found, spawn a new one
96 if (!bFound)
97 {
99 VectorToClusterMap[k] = k;
100 M++;
101 }
102 }
103 }
104
105
106};
107
110
111} // end namespace UE::Geometry
112} // end namespace UE
#define check(expr)
Definition AssertionMacros.h:314
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
Definition Array.h:670
void SetNum(SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2308
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
UE_FORCEINLINE_HINT void Reserve(SizeType Number)
Definition Array.h:3016
Definition AssetRegistryState.h:50
Definition MathUtil.h:150
static RealType Cos(const RealType Value)
Definition MathUtil.h:372
Definition VectorSetAnalysis.h:20
TArray< int32 > VectorToClusterMap
Definition VectorSetAnalysis.h:37
void Initialize(EnumerableIDType EnumerableIDs, TFunctionRef< TVector< RealType >(int32)> GetVectorFunc, int32 NumVectorsHint=0, bool bIsNormalizedHint=false)
Definition VectorSetAnalysis.h:46
TArray< int32 > VectorIDs
Definition VectorSetAnalysis.h:27
TArray< TVector< RealType > > Vectors
Definition VectorSetAnalysis.h:26
int32 NumClusters() const
Definition VectorSetAnalysis.h:63
int32 NumVectors() const
Definition VectorSetAnalysis.h:60
bool bNormalized
Definition VectorSetAnalysis.h:28
TArray< TVector< RealType > > ClusterVectors
Definition VectorSetAnalysis.h:35
void GreedyClusterVectors(RealType AngleToleranceDeg)
Definition VectorSetAnalysis.h:71
TVectorSetAnalysis3< double > FVectorSetAnalysis3d
Definition VectorSetAnalysis.h:109
TVectorSetAnalysis3< float > FVectorSetAnalysis3f
Definition VectorSetAnalysis.h:108
Definition Sphere.cpp:10
Definition AdvancedWidgetsModule.cpp:13
Definition Vector.h:51