UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Geometry::FClusterKMeans Struct Reference

#include <KMeans.h>

Public Member Functions

template<typename TVectorType = FVector, bool bRunParallel = false>
int32 ComputeClusters (TArrayView< const TVectorType > PointsToCluster, int32 NumClusters, TArrayView< const TVectorType > InitialCenters=TArrayView< const TVectorType >(), TArray< TVectorType > *OutClusterCenters=nullptr)
 
template<typename TVectorType = FVector>
void GetUniformSpacedInitialCenters (TArrayView< const TVectorType > PointsToCluster, int32 NumClusters, TArray< TVectorType > &OutCenters)
 
void GEOMETRYCORE_API GetClusters (TArray< TArray< int32 > > &OutClusters)
 

Public Attributes

int32 MaxIterations = 500
 Parameters.
 
int32 RandomSeed = 0
 
TArray< int32ClusterIDs
 Outputs.
 
TArray< std::atomic< int32 > > ClusterSizes
 

Member Function Documentation

◆ ComputeClusters()

template<typename TVectorType = FVector, bool bRunParallel = false>
int32 UE::Geometry::FClusterKMeans::ComputeClusters ( TArrayView< const TVectorType PointsToCluster,
int32  NumClusters,
TArrayView< const TVectorType InitialCenters = TArrayView<const TVectorType>(),
TArray< TVectorType > *  OutClusterCenters = nullptr 
)
inline

Compute the K-Means clustering of FVector points

Parameters
PointsToClusterPoints to partition into clusters
NumClustersTarget number of clusters to create, if InitialCenters is not provided
InitialCentersIf non-empty, these positions will be used to initialize the cluster locations
OutClusterCentersIf non-null, will be filled with the cluster centers
bRunParallelRuns a parallel algorithm (faster) if possible. The output might be non-deterministic when running in parallel
Returns
number of clusters found

◆ GetClusters()

void UE::Geometry::FClusterKMeans::GetClusters ( TArray< TArray< int32 > > &  OutClusters)

◆ GetUniformSpacedInitialCenters()

template<typename TVectorType = FVector>
void UE::Geometry::FClusterKMeans::GetUniformSpacedInitialCenters ( TArrayView< const TVectorType PointsToCluster,
int32  NumClusters,
TArray< TVectorType > &  OutCenters 
)
inline

Helper function to generate (approximately) uniform-spaced initial clusters centers, which can be passed to ComputeClusters.

Member Data Documentation

◆ ClusterIDs

TArray<int32> UE::Geometry::FClusterKMeans::ClusterIDs

Outputs.

◆ ClusterSizes

TArray<std::atomic<int32> > UE::Geometry::FClusterKMeans::ClusterSizes

◆ MaxIterations

int32 UE::Geometry::FClusterKMeans::MaxIterations = 500

Parameters.

◆ RandomSeed

int32 UE::Geometry::FClusterKMeans::RandomSeed = 0

The documentation for this struct was generated from the following files: