UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PlaneTypes.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3// Port of geometry3sharp Plane3
4
5#pragma once
6
7#include "VectorTypes.h"
8#include "VectorUtil.h"
9#include "Math/Plane.h"
10#include "Math/Transform.h"
11
12namespace UE
13{
14namespace Geometry
15{
16
17using namespace UE::Math;
18
19template<typename RealType>
20struct TPlane3
21{
23 RealType Constant;
24
26
30
37
47
48 explicit TPlane3(const FPlane& Plane) : TPlane3(Plane.GetNormal(), Plane.W)
49 {
50 }
51
52 explicit operator FPlane() const
53 {
55 }
56
61 {
63 // Transform the normal
65 // Update the plane constant using the transformed normal and origin
67 }
68
73 {
74 TVector<RealType> TransformedOrigin = Tr.InverseTransformPosition(Normal * Constant);
75 // Inverse transform the normal
77 // Update the plane constant using the transformed normal and origin
79 }
80
89 {
90 return Normal.Dot(P) - Constant;
91 }
92
100 {
101 double Distance = DistanceTo(P);
102 if (Distance < 0)
103 {
104 return -1;
105 }
106 else if (Distance > 0)
107 {
108 return +1;
109 }
110 else
111 {
112 return 0;
113 }
114 }
115
116
117
118
141
142
150
162 {
163 RealType Dist0 = DistanceTo(Point0);
164 RealType Dist1 = DistanceTo(Point1);
165 if (Dist0 <= 0 && Dist1 <= 0)
166 {
168 }
169 else if (Dist0 * Dist1 > 0)
170 {
172 }
173
174 TVector<RealType> DirectionVec = Point1 - Point0;
176 RealType Length = DirectionVec.Dot(Direction);
177
178 // test if segment is parallel to plane, if so, no intersection
179 RealType NormalDot = Direction.Dot(Normal);
181 {
183 }
184
185 RealType LineT = -Dist0 / NormalDot; // calculate line parameter for line/plane intersection
186 if (LineT > 0 && LineT < Length) // verify segment intersection (should always be true...)
187 {
188 if (NormalDot < 0)
189 {
190 Point1 = Point0 + LineT * Direction;
192 }
193 else
194 {
195 Point0 += LineT * Direction;
197 }
198 }
200 }
201
202};
203
206
207} // end namespace UE::Geometry
208} // end namespace UE
209
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::Math::TPlane< double > FPlane
Definition MathFwd.h:52
Definition MathUtil.h:150
TVector< RealType > TransformNormal(const TTransform< RealType > &Transform, const TVector< RealType > &Normal)
Definition VectorUtil.h:634
TVector< RealType > InverseTransformNormal(const TTransform< RealType > &Transform, const TVector< RealType > &Normal)
Definition VectorUtil.h:644
TVector< RealType > Normal(const TVector< RealType > &V0, const TVector< RealType > &V1, const TVector< RealType > &V2)
Definition VectorUtil.h:70
TPlane3< float > FPlane3f
Definition PlaneTypes.h:204
TPlane3< double > FPlane3d
Definition PlaneTypes.h:205
Definition Sphere.cpp:10
Definition AdvancedWidgetsModule.cpp:13
Definition NumericLimits.h:41
Definition PlaneTypes.h:21
int WhichSide(const UE::Math::TVector< RealType > &P) const
Definition PlaneTypes.h:99
TPlane3(const UE::Math::TVector< RealType > &Normal, double Constant)
Definition PlaneTypes.h:27
bool FindLineIntersection(const UE::Math::TVector< RealType > &LineOrigin, const UE::Math::TVector< RealType > &LineDirection, UE::Math::TVector< RealType > &IntersectionPointOut) const
Definition PlaneTypes.h:126
TPlane3(const UE::Math::TVector< RealType > &Normal, const UE::Math::TVector< RealType > &Point)
Definition PlaneTypes.h:34
double DistanceTo(const UE::Math::TVector< RealType > &P) const
Definition PlaneTypes.h:88
RealType Constant
Definition PlaneTypes.h:23
TPlane3(const FPlane &Plane)
Definition PlaneTypes.h:48
void Transform(const TTransform< RealType > &Tr)
Definition PlaneTypes.h:60
EClipSegmentType ClipSegment(UE::Math::TVector< RealType > &Point0, UE::Math::TVector< RealType > &Point1) const
Definition PlaneTypes.h:161
TPlane3(const UE::Math::TVector< RealType > &P0, const UE::Math::TVector< RealType > &P1, const UE::Math::TVector< RealType > &P2)
Definition PlaneTypes.h:42
EClipSegmentType
Definition PlaneTypes.h:144
@ NotClipped
Definition PlaneTypes.h:148
@ FirstClipped
Definition PlaneTypes.h:146
@ FullyClipped
Definition PlaneTypes.h:145
@ SecondClipped
Definition PlaneTypes.h:147
TVector< RealType > Normal
Definition PlaneTypes.h:22
TPlane3()
Definition PlaneTypes.h:25
void InverseTransform(const TTransform< RealType > &Tr)
Definition PlaneTypes.h:72
Definition TransformNonVectorized.h:39
Definition Vector.h:51
T Z
Definition Vector.h:68
T Y
Definition Vector.h:65
T X
Definition Vector.h:62
UE_FORCEINLINE_HINT T Dot(const TVector< T > &V) const
Definition Vector.h:1553