UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
HalfspaceTypes.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Math/UnrealMath.h"
6#include "VectorTypes.h"
7#include "VectorUtil.h"
8
9namespace UE
10{
11namespace Geometry
12{
13
14using namespace UE::Math;
15
16/*
17 * 3D Halfspace stored as parameters to Plane Equation (Normal, Normal.Dot(PointOnPlane))
18 * The Normal points "into" the halfspace, ie X is inside if (Normal.Dot(X) - Constant) >= 0
19 */
20template<typename T>
22{
23public:
27 T Constant = (T)0;
28
29 THalfspace3() = default;
30
33
34 THalfspace3(T NormalX, T NormalY, T NormalZ, T ConstantIn)
35 : Normal(NormalX,NormalY,NormalZ), Constant(ConstantIn) {}
36
37
41
43 THalfspace3(const TVector<T>& P0, const TVector<T>& P1, const TVector<T>& P2)
44 {
45 Normal = VectorUtil::Normal(P0, P1, P2);
46 Constant = Normal.Dot(P0);
47 }
48
49
51 bool Contains(const TVector<T>& Point) const
52 {
53 return (Normal.Dot(Point) - Constant) >= 0;
54 }
55
56};
57
58
61
62
63} // end namespace UE::Geometry
64} // end namespace UE
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
TVector< RealType > Normal(const TVector< RealType > &V0, const TVector< RealType > &V1, const TVector< RealType > &V2)
Definition VectorUtil.h:70
THalfspace3< float > FHalfspace3f
Definition HalfspaceTypes.h:59
THalfspace3< double > FHalfspace3d
Definition HalfspaceTypes.h:60
Definition Sphere.cpp:10
Definition AdvancedWidgetsModule.cpp:13
Definition HalfspaceTypes.h:22
TVector< T > Normal
Definition HalfspaceTypes.h:25
THalfspace3(T NormalX, T NormalY, T NormalZ, T ConstantIn)
Definition HalfspaceTypes.h:34
THalfspace3(const TVector< T > &P0, const TVector< T > &P1, const TVector< T > &P2)
Definition HalfspaceTypes.h:43
THalfspace3(const TVector< T > &PlaneNormalIn, const TVector< T > &PlanePoint)
Definition HalfspaceTypes.h:39
T Constant
Definition HalfspaceTypes.h:27
THalfspace3(const TVector< T > &PlaneNormalIn, T ConstantIn)
Definition HalfspaceTypes.h:31
bool Contains(const TVector< T > &Point) const
Definition HalfspaceTypes.h:51
Definition Vector.h:51
static TVector< T > UnitY()
Definition Vector.h:121