33#include <NDEVR/Vertex.h>
34#include <NDEVR/LineSegment.h>
35#include <NDEVR/Matrix.h>
44 template<u
int01 t_dims,
class t_type>
62 normal = (
cross(edge1, edge2)).template normalized<t_type>();
74 template<u
int01 t_new_dims,
class t_new_type>
86 else if (dot_product < 0)
119 if (
abs(Vd) < epsilon)
123 t_type distance_along_line = -V0 / Vd;
124 return distance_along_line;
139 right = right.template normalized<t_type>();
146 , offset[
X], offset[
Y], offset[
Z], 1);
149 template<
class t_buffer_type>
152 const uint04 vertex_size = points.size();
153 lib_assert(vertex_size >= 3,
"Plane requires at least 3 points");
162 for(
uint04 i = 0; i < vertex_size; i++)
165 v =
cross((p3 - p2), (p1 - p2));
166 if(v[t_dims - 1] != 0)
171 centroid += points[i];
177 v =
cross((p3 - p2), (p1 - p2));
178 if(v[t_dims - 1] != 0)
184 v =
cross((p3 - p2), (p1 - p2));
188 n = n.template normalized<t_type>();
189 if (
dot(direction_reference, n) < 0)
202 return (
equals(
normal, plane.normal, epsilon) &&
abs(
d - plane.d) < epsilon)
208 return normal == plane.normal &&
d == plane.d;
212 return normal != plane.normal ||
d != plane.d;
229 template<u
int01 t_dims,
class t_type>
253 template<u
int01 t_dims,
class t_type>
254 static constexpr bool isNaN(
const Plane<t_dims, t_type>& value)
256 return isNaN(value.normal) || isNaN(value.d);
259 template<
class t_type, u
int01 t_row_dims, u
int01 t_col_dims>
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
A line segment represented by two vertices, a start and end.
Definition Line.hpp:55
constexpr t_vertex ray() const
Definition Line.hpp:134
Definition Matrix.hpp:173
t_type d
Definition Plane.hpp:216
Matrix< t_type > projectionMatrix(const Vector< 3, t_type > &up) const
Definition Plane.hpp:134
constexpr void negate()
Definition Plane.hpp:69
constexpr Plane(const Ray< t_dims, t_type > &_normal, t_type _d)
Definition Plane.hpp:65
bool isAbovePlane(const Vector< t_dims, t_type > &pos) const
Definition Plane.hpp:91
bool operator==(const Plane &plane) const
Definition Plane.hpp:206
t_type calculateIntersectionPos(const LineSegment< t_dims, t_type > &line, t_type epsilon) const
Definition Plane.hpp:114
bool liesOnPlane(const Vector< t_dims, t_type > &pos) const
Definition Plane.hpp:99
Plane< t_new_dims, t_new_type > as() const
Definition Plane.hpp:75
t_type distanceTo(const Vector< t_dims, t_type > &pos) const
Definition Plane.hpp:103
constexpr Plane(const Ray< t_dims, t_type > &_normal, const Vertex< t_dims, t_type > &_p)
Definition Plane.hpp:52
Vertex< t_dims, t_type > nearestPosition(const Vector< 3, fltp08 > &pos) const
Definition Plane.hpp:108
PlanePosition planePosition(const Vector< t_dims, t_type > &pos) const
Definition Plane.hpp:81
Vertex< t_dims, t_type > calculateIntersection(const LineSegment< t_dims, t_type > &line, t_type epsilon) const
Definition Plane.hpp:127
bool operator!=(const Plane &plane) const
Definition Plane.hpp:210
constexpr Plane(const Vertex< t_dims, t_type > &a, const Vertex< t_dims, t_type > &b, const Vertex< t_dims, t_type > &c)
Definition Plane.hpp:56
bool isBelowPlane(const Vector< t_dims, t_type > &pos) const
Definition Plane.hpp:95
Ray< t_dims, t_type > normal
Definition Plane.hpp:215
bool contains(const Vector< 3, t_type > &point, t_type epsilon) const
Definition Plane.hpp:195
bool isSamePlane(const Plane &plane, t_type epsilon) const
Definition Plane.hpp:200
Plane()
Definition Plane.hpp:48
static Plane CreateBestFitPlane(const t_buffer_type &points, const Vector< t_dims, t_type > &direction_reference=Vector< t_dims, t_type >(0, 0, 1))
Definition Plane.hpp:150
Definition Vertex.hpp:341
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
A vertex.
Definition Vertex.hpp:54
constexpr std::enable_if< IsVecType< t_vector_type, Angle< fltp08 > >::value, t_vector_type >::type operator*(const t_vector_type &angle, const t_type &mult)
Definition AngleFunctions.h:403
t_type dot(const Vector< t_dims, t_type > &v1, const Vector< t_dims, t_type > &v2)
Definition VectorFunctions.hpp:1096
PlanePosition
Definition Plane.hpp:39
constexpr Vector< 1, t_type > cross(const Vector< 1, t_type > &, const Vector< 1, t_type > &)
Definition VectorFunctions.hpp:954
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
constexpr bool equals(const LineSegment< t_dims, t_type, t_vertex > &left, const LineSegment< t_dims, t_type, t_vertex > &right, const t_type &epsilon=cast< t_type >(0))
Definition Line.hpp:819
constexpr Angle< t_angle_type > abs(const Angle< t_angle_type > &value)
Definition AngleFunctions.h:750
@ A
Definition BaseValues.hpp:201
@ Y
Definition BaseValues.hpp:202
@ X
Definition BaseValues.hpp:200
@ Z
Definition BaseValues.hpp:204
Definition BaseValues.hpp:272
static const t_type NaN
Definition BaseValues.hpp:274