UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FitOrientedBox2.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 "Math/Vector.h"
7#include "VectorTypes.h"
8#include "OrientedBoxTypes.h"
9
10namespace UE
11{
12namespace Geometry
13{
14
20
21
30 template <typename RealType>
31 TOrientedBox2<RealType> GEOMETRYCORE_API FitOrientedBox2Points(TArrayView<const TVector2<RealType>> Points, TFunctionRef<RealType(RealType, RealType)> FitFn);
32
41 template <typename RealType>
43 {
45 {
46 return FitOrientedBox2Points(Points, (TFunctionRef<RealType(RealType, RealType)>)[](RealType W, RealType H) -> RealType
47 {
48 return W * H;
49 });
50 }
51 else // perimeter
52 {
53 return FitOrientedBox2Points(Points, (TFunctionRef<RealType(RealType, RealType)>)[](RealType W, RealType H) -> RealType
54 {
55 return W + H; // Note: ok to skip constant factor
56 });
57 }
58 }
59
60
69 template <typename RealType>
70 TOrientedBox2<RealType> GEOMETRYCORE_API FitOrientedBox2SimplePolygon(TArrayView<const TVector2<RealType>> Polygon, TFunctionRef<RealType(RealType, RealType)> FitFn);
71
80 template <typename RealType>
82 {
84 {
85 return FitOrientedBox2SimplePolygon(Polygon, (TFunctionRef<RealType(RealType, RealType)>)[](RealType W, RealType H) -> RealType
86 {
87 return W * H;
88 });
89 }
90 else // perimeter
91 {
92 return FitOrientedBox2SimplePolygon(Polygon, (TFunctionRef<RealType(RealType, RealType)>)[](RealType W, RealType H) -> RealType
93 {
94 return W + H; // Note: ok to skip constant factor
95 });
96 }
97 }
98
99
100
109 template <typename RealType>
111
120 template <typename RealType>
122 {
124 {
125 return FitOrientedBox2ConvexHull(NumPts, GetHullPt, (TFunctionRef<RealType(RealType, RealType)>)[](RealType W, RealType H) -> RealType
126 {
127 return W * H;
128 });
129 }
130 else // perimeter
131 {
132 return FitOrientedBox2ConvexHull(NumPts, GetHullPt, (TFunctionRef<RealType(RealType, RealType)>)[](RealType W, RealType H) -> RealType
133 {
134 return W + H; // Note: ok to skip constant factor
135 });
136 }
137 }
138
139 // TODO: also have versions for a convex polygon input (+ a near-convex polygon version, that tolerates/fixes 'small' defects?)
140
141} // end namespace Geometry
142}// end namespace UE
143
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 ArrayView.h:139
Definition AssetRegistryState.h:50
TOrientedBox2< RealType > FitOrientedBox2Points(TArrayView< const TVector2< RealType > > Points, TFunctionRef< RealType(RealType, RealType)> FitFn)
Definition FitOrientedBox2.cpp:205
TOrientedBox2< RealType > FitOrientedBox2ConvexHull(int32 NumPts, TFunctionRef< TVector2< RealType >(int32)> GetHullPt, TFunctionRef< RealType(RealType, RealType)> FitFn)
Definition FitOrientedBox2.cpp:19
TOrientedBox2< RealType > FitOrientedBox2SimplePolygon(TArrayView< const TVector2< RealType > > Polygon, TFunctionRef< RealType(RealType, RealType)> FitFn)
Definition FitOrientedBox2.cpp:179
EBox2FitCriteria
Definition FitOrientedBox2.h:16
@ Area
Definition FitOrientedBox2.h:17
@ Perimeter
Definition FitOrientedBox2.h:18
Definition AdvancedWidgetsModule.cpp:13
Definition OrientedBoxTypes.h:315
Definition Vector2D.h:38