UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
NormalHistogram.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "MathUtil.h"
6#include "VectorTypes.h"
8
9namespace UE
10{
11namespace Geometry
12{
13
14using namespace UE::Math;
15
23template<typename RealType>
25{
26public:
30
35 {
36 Bins = NumBins;
39 }
40
45 void Count(const TVector<RealType>& Normal, RealType Weight = 1)
46 {
47 int32 BinIndex = BinPoints.FindIndex(Normal);
48 WeightedCounts[BinIndex] += Weight;
49 }
50
55 {
56 int MaxIndex = 0;
57 for (int k = 1; k < Bins; ++k)
58 {
59 if (WeightedCounts[k] > WeightedCounts[MaxIndex])
60 {
61 MaxIndex = k;
62 }
63 }
64 return BinPoints[MaxIndex];
65 }
66
67
71 RealType WeightedSpreadMetric() const
72 {
74 RealType TotalWeightedCount = 0;
75 for (int k = 0; k < Bins; ++k)
76 {
77 if (WeightedCounts[k] > 0)
78 {
81 }
82 }
83
84 RealType Metric = 0;
85 for (int32 k = 0; k < Bins; ++k)
86 {
87 if (WeightedCounts[k] > 0)
88 {
90 MassFraction /= (RealType)NumOccupiedBins;
91 Metric += MassFraction;
92 }
93 }
94
95 return 1.0 / Metric;
96 }
97};
98
99
100
101} // end namespace UE::Geometry
102} // end namespace UE
@ Normal
Definition AndroidInputInterface.h:116
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 Init(const ElementType &Element, SizeType Number)
Definition Array.h:3043
Definition NormalHistogram.h:25
RealType WeightedSpreadMetric() const
Definition NormalHistogram.h:71
int32 Bins
Definition NormalHistogram.h:27
TNormalHistogram(int32 NumBins)
Definition NormalHistogram.h:34
void Count(const TVector< RealType > &Normal, RealType Weight=1)
Definition NormalHistogram.h:45
TSphericalFibonacci< RealType > BinPoints
Definition NormalHistogram.h:28
TVector< RealType > FindMaxNormal() const
Definition NormalHistogram.h:54
TArray< RealType > WeightedCounts
Definition NormalHistogram.h:29
Definition SphericalFibonacci.h:26
Definition Sphere.cpp:10
Definition AdvancedWidgetsModule.cpp:13
Definition Vector.h:51