5#ifndef __IRR_PLANE_3D_H_INCLUDED__
6#define __IRR_PLANE_3D_H_INCLUDED__
46 { setPlane(point1, point2, point3); }
52 inline bool operator==(
const plane3d<T>& other)
const {
return (
equals(
D, other.
D) &&
Normal==other.
Normal);}
54 inline bool operator!=(
const plane3d<T>& other)
const {
return !(*
this == other);}
73 Normal = (point2 - point1).crossProduct(point3 - point1);
90 T t2 =
Normal.dotProduct(lineVect);
95 T t =- (
Normal.dotProduct(linePoint) +
D) / t2;
96 outIntersection = linePoint + (lineVect * t);
112 return (
f32)-((
Normal.dotProduct(linePoint1) +
D) / t2);
137 const T d =
Normal.dotProduct(point) +
D;
139 if (d < -ROUNDING_ERROR_f32)
142 if (d > ROUNDING_ERROR_f32)
143 return ISREL3D_FRONT;
145 return ISREL3D_PLANAR;
165 return cross.
getLength() > core::ROUNDING_ERROR_f32;
177 const T fn00 =
Normal.getLength();
179 const T fn11 = other.
Normal.getLength();
180 const f64 det = fn00*fn11 - fn01*fn01;
182 if (fabs(det) < ROUNDING_ERROR_f64 )
185 const f64 invdet = 1.0 / det;
186 const f64 fc0 = (fn11*-
D + fn01*other.
D) * invdet;
187 const f64 fc1 = (fn00*-other.
D + fn01*
D) * invdet;
216 const f32 d =
Normal.dotProduct(lookDirection);
217 return F32_LOWER_EQUAL_0 ( d );
Template plane class with some intersection testing methods.
Definition plane3d.h:34
EIntersectionRelation3D classifyPointRelation(const vector3d< T > &point) const
Classifies the relation of a point to this plane.
Definition plane3d.h:135
vector3d< T > getMemberPoint() const
Gets a member point of the plane.
Definition plane3d.h:155
f32 getKnownIntersectionWithLine(const vector3d< T > &linePoint1, const vector3d< T > &linePoint2) const
Get percentage of line between two points where an intersection with this plane happens.
Definition plane3d.h:107
bool existsIntersection(const plane3d< T > &other) const
Tests if there is an intersection with the other plane.
Definition plane3d.h:162
void recalculateD(const vector3d< T > &MPoint)
Recalculates the distance from origin by applying a new member point to the plane.
Definition plane3d.h:149
bool getIntersectionWithLimitedLine(const vector3d< T > &linePoint1, const vector3d< T > &linePoint2, vector3d< T > &outIntersection) const
Get an intersection with a 3d line, limited between two 3d points.
Definition plane3d.h:121
vector3d< T > Normal
Normal vector of the plane.
Definition plane3d.h:228
bool getIntersectionWithPlanes(const plane3d< T > &o1, const plane3d< T > &o2, vector3d< T > &outPoint) const
Get the intersection point with two other planes if there is one.
Definition plane3d.h:195
bool getIntersectionWithPlane(const plane3d< T > &other, vector3d< T > &outLinePoint, vector3d< T > &outLineVect) const
Intersects this plane with another.
Definition plane3d.h:173
T getDistanceTo(const vector3d< T > &point) const
Get the distance to a point.
Definition plane3d.h:222
bool isFrontFacing(const vector3d< T > &lookDirection) const
Test if the triangle would be front or backfacing from any point.
Definition plane3d.h:214
bool getIntersectionWithLine(const vector3d< T > &linePoint, const vector3d< T > &lineVect, vector3d< T > &outIntersection) const
Get an intersection with a 3d line.
Definition plane3d.h:86
T D
Distance from origin.
Definition plane3d.h:231
3d vector template class with lots of operators and methods.
Definition vector3d.h:23
T getLength() const
Get length of the vector.
Definition vector3d.h:117
bool isBetweenPoints(const vector3d< T > &begin, const vector3d< T > &end) const
Returns if this vector interpreted as a point is on a line between two other points.
Definition vector3d.h:157
T dotProduct(const vector3d< T > &other) const
Get the dot product with another vector.
Definition vector3d.h:125
Basic classes such as vectors, planes, arrays, lists, and so on can be found in this namespace.
Definition aabbox3d.h:15
EIntersectionRelation3D
Enumeration for intersection relations of 3d objects.
Definition plane3d.h:18
bool equals(const f64 a, const f64 b, const f64 tolerance=ROUNDING_ERROR_f64)
returns if a equals b, taking possible rounding errors into account
Definition irrMath.h:185
plane3d< f32 > plane3df
Typedef for a f32 3d plane.
Definition plane3d.h:236
plane3d< s32 > plane3di
Typedef for an integer 3d plane.
Definition plane3d.h:239
Everything in the Irrlicht Engine can be found in this namespace.
Definition Skylicht.h:33
float f32
32 bit floating point variable.
Definition irrTypes.h:104
double f64
64 bit floating point variable.
Definition irrTypes.h:108