UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GridIndexing2.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3// Port of geometry3Sharp GridIndexing2
4
5#pragma once
6
7#include "VectorTypes.h"
8#include "IntVectorTypes.h"
9#include "Math/IntRect.h"
10
11namespace UE
12{
13namespace Geometry
14{
15
16using namespace UE::Math;
17
21template<typename RealType>
53
54
58template<typename RealType>
60{
62 RealType CellSize;
65
66 TShiftGridIndexer2(const TVector2<RealType>& origin, RealType cellSize)
67 {
68 Origin = origin;
69 CellSize = cellSize;
71 }
72
75 {
76 return FVector2i(
79 }
80
82 inline FIntRect ToGrid(const TBox2<RealType>& Box) const
83 {
84 const FVector2i Min = ToGrid(Box.Min);
85 const FVector2i Max = ToGrid(Box.Max);
86 return FIntRect(Min.X, Min.Y, Max.X, Max.Y);
87 }
88
90 inline FIntRect ToGrid(const TBox<RealType>& Box) const
91 {
94 return FIntRect(Min.X, Min.Y, Max.X, Max.Y);
95 }
96
99 {
100 return TVector2<RealType>(
101 ((RealType)GridPoint.X * CellSize) + Origin.X,
102 ((RealType)GridPoint.Y * CellSize) + Origin.Y);
103 }
104
107 {
108 return TVector2<RealType>(
109 ((RealType)RealGridPoint.X * CellSize) + Origin.X,
110 ((RealType)RealGridPoint.Y * CellSize) + Origin.Y);
111 }
112
120};
123
124
125} // end namespace UE::Geometry
126} // end namespace UE
#define ensure( InExpression)
Definition AssertionMacros.h:464
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::Math::TIntRect< int32 > FIntRect
Definition MathFwd.h:133
Definition MathUtil.h:150
TScaleGridIndexer2< double > FScaleGridIndexer2d
Definition GridIndexing2.h:52
TShiftGridIndexer2< double > FShiftGridIndexer2d
Definition GridIndexing2.h:122
TScaleGridIndexer2< float > FScaleGridIndexer2f
Definition GridIndexing2.h:51
TShiftGridIndexer2< float > FShiftGridIndexer2f
Definition GridIndexing2.h:121
Definition Sphere.cpp:10
Definition AdvancedWidgetsModule.cpp:13
Definition IntVectorTypes.h:20
Definition GridIndexing2.h:23
TScaleGridIndexer2(RealType CellSize)
Definition GridIndexing2.h:32
TScaleGridIndexer2()
Definition GridIndexing2.h:27
RealType CellSize
Definition GridIndexing2.h:25
TVector2< RealType > FromGrid(const FVector2i &GridPoint) const
Definition GridIndexing2.h:46
FVector2i ToGrid(const TVector2< RealType > &P) const
Definition GridIndexing2.h:38
Definition GridIndexing2.h:60
RealType CellSize
Definition GridIndexing2.h:62
TVector2< RealType > FromGrid(const FVector2i &GridPoint) const
Definition GridIndexing2.h:98
FIntRect ToGrid(const TBox< RealType > &Box) const
Definition GridIndexing2.h:90
TVector2< RealType > FromGrid(const TVector2< RealType > &RealGridPoint) const
Definition GridIndexing2.h:106
TVector2< RealType > Origin
Definition GridIndexing2.h:64
FIntRect ToGrid(const TBox2< RealType > &Box) const
Definition GridIndexing2.h:82
TShiftGridIndexer2(const TVector2< RealType > &origin, RealType cellSize)
Definition GridIndexing2.h:66
TBox2< RealType > BoxFromGrid(const FVector2i &GridPoint) const
Definition GridIndexing2.h:114
FVector2i ToGrid(const TVector2< RealType > &Point) const
Definition GridIndexing2.h:74
Definition Box2D.h:31
Definition Box.h:35
Definition Vector2D.h:38
T Y
Definition Vector2D.h:52
T X
Definition Vector2D.h:49