Unravel Engine C++ Reference
Loading...
Searching...
No Matches
plane.h
Go to the documentation of this file.
1#pragma once
2
3#include "transform.hpp"
4#include <glm/glm.hpp>
5#include <glm/gtc/matrix_transform.hpp>
6
7namespace math
8{
9using namespace glm;
10
11//-----------------------------------------------------------------------------
12// Main class declarations
13//-----------------------------------------------------------------------------
14//-----------------------------------------------------------------------------
15// Name : plane (Class)
19//-----------------------------------------------------------------------------
20struct plane
21{
22 //-------------------------------------------------------------------------
23 // Friend List
24 //-------------------------------------------------------------------------
25
35 friend auto operator*(float s, const plane& p) -> plane;
36
37 //-------------------------------------------------------------------------
38 // Constructors & Destructors
39 //-------------------------------------------------------------------------
40
47
55 plane(const vec4& p);
56
67 plane(float _a, float _b, float _c, float _d);
68
69 //-------------------------------------------------------------------------
70 // Public Static Methods
71 //-------------------------------------------------------------------------
72
80 static auto dot(const plane& p, const vec4& v) -> float;
81
89 static auto dot_coord(const plane& p, const vec3& v) -> float;
90
98 static auto dot_normal(const plane& p, const vec3& v) -> float;
99
107 static auto from_point_normal(const vec3& point, const vec3& normal) -> plane;
108
117 static auto from_points(const vec3& v1, const vec3& v2, const vec3& v3) -> plane;
118
126 static auto mul(const plane& p, const mat4& m) -> plane;
127
136 static auto normalize(const plane& p) -> plane;
137
147 static auto scale(const plane& p, float s) -> plane;
148
149 //-------------------------------------------------------------------------
150 // Public Operators
151 //-------------------------------------------------------------------------
158 auto operator*(float s) const -> plane;
159
166 auto operator/(float s) const -> plane;
167
174 auto operator*=(float s) -> plane&;
175
182 auto operator/=(float s) -> plane&;
183
189 auto operator+() const -> plane;
190
198 auto operator-() const -> plane;
199
208 auto operator==(const plane& p) const -> bool;
209
218 auto operator!=(const plane& p) const -> bool;
219
228 auto operator=(const vec4& rhs) -> plane&;
229
230 //-------------------------------------------------------------------------
231 // Public Members
232 //-------------------------------------------------------------------------
233
240 vec4 data = {0.0f, 0.0f, 0.0f, 0.0f};
241};
242
243//-----------------------------------------------------------------------------
244// Global Inline Operators (plane)
245//-----------------------------------------------------------------------------
255inline auto operator*(float s, const plane& p) -> plane
256{
257 return plane(p.data * s);
258}
259} // namespace math
btVector3 normal
float scale
Definition hub.cpp:25
Definition bbox.cpp:5
auto operator*(float s, const plane &p) -> plane
Scalar multiplication for a plane.
Definition plane.h:255
Storage for infinite plane.
Definition plane.h:21
auto operator*=(float s) -> plane &
Multiplies and assigns the plane by a scalar value.
Definition plane.cpp:58
static auto normalize(const plane &p) -> plane
Normalizes the plane.
Definition plane.cpp:37
static auto from_point_normal(const vec3 &point, const vec3 &normal) -> plane
Creates a plane from a point and a normal.
Definition plane.cpp:20
auto operator+() const -> plane
Unary plus operator.
Definition plane.cpp:70
friend auto operator*(float s, const plane &p) -> plane
Scalar multiplication for a plane.
Definition plane.h:255
auto operator/(float s) const -> plane
Divides the plane by a scalar value.
Definition plane.cpp:53
static auto from_points(const vec3 &v1, const vec3 &v2, const vec3 &v3) -> plane
Creates a plane from three points.
Definition plane.cpp:26
static auto dot_normal(const plane &p, const vec3 &v) -> float
Computes the dot product of the plane normal and a vec3.
Definition plane.cpp:15
auto operator/=(float s) -> plane &
Divides and assigns the plane by a scalar value.
Definition plane.cpp:64
plane()
Default constructor.
static auto dot(const plane &p, const vec4 &v) -> float
Computes the dot product of the plane and a vec4.
Definition plane.cpp:5
static auto dot_coord(const plane &p, const vec3 &v) -> float
Computes the dot product of the plane and a vec3 (considering the plane's distance).
Definition plane.cpp:10
static auto mul(const plane &p, const mat4 &m) -> plane
Transforms a plane by a 4x4 matrix.
Definition plane.cpp:32
vec4 data
The components of the plane.
Definition plane.h:240