Saga3D API Documentation
1.0-RC4
|
Go to the documentation of this file.
5 #ifndef __IRR_PLANE_3D_H_INCLUDED__
6 #define __IRR_PLANE_3D_H_INCLUDED__
9 #include <glm/vec3.hpp>
10 #include <glm/gtc/matrix_inverse.hpp>
46 plane3d(
const glm::vec3& point1,
const glm::vec3& point2,
const glm::vec3& point3)
47 {
setPlane(point1, point2, point3); }
59 void setPlane(
const glm::vec3& point,
const glm::vec3& nvector)
71 void setPlane(
const glm::vec3& point1,
const glm::vec3& point2,
const glm::vec3& point3)
74 Normal = glm::cross(point2 - point1, point3 - point1);
87 auto transposedInverse = glm::inverseTranspose(mat);
88 auto normal = transposedInverse * glm::vec4(
Normal, 1) ;
100 const glm::vec3& lineVect,
101 glm::vec3& outIntersection)
const
103 T t2 = glm::dot(
Normal, lineVect);
108 T t =- (glm::dot(
Normal, linePoint) +
D) / t2;
109 outIntersection = linePoint + (lineVect * t);
121 const glm::vec3& linePoint2)
const
123 glm::vec3 vect = linePoint2 - linePoint1;
124 T t2 = (float) glm::dot(
Normal, vect);
125 return (
float)-((glm::dot(
Normal, linePoint1) +
D) / t2);
135 const glm::vec3& linePoint1,
136 const glm::vec3& linePoint2,
137 glm::vec3& outIntersection)
const
150 const T d = glm::dot(
Normal, point) +
D;
164 D = - glm::dot(MPoint,
Normal);
187 glm::vec3& outLinePoint,
188 glm::vec3& outLineVect)
const
190 const T fn00 = glm::length(
Normal);
192 const T fn11 = glm::length(other.
Normal);
193 const double det = fn00*fn11 - fn01*fn01;
198 const double invdet = 1.0 / det;
199 const double fc0 = (fn11*-
D + fn01*other.
D) * invdet;
200 const double fc1 = (fn00*-other.
D + fn01*
D) * invdet;
209 const plane3d<T>& o2, glm::vec3& outPoint)
const
211 glm::vec3 linePoint, lineVect;
229 const float d = glm::dot(
Normal, lookDirection);
237 return glm::dot(point,
Normal) +
D;
plane3d(T px, T py, T pz, T nx, T ny, T nz)
Template plane class with some intersection testing methods.
void transform(const glm::mat4 &mat)
plane3d(const glm::vec3 &MPoint, const glm::vec3 &Normal)
void setPlane(const glm::vec3 &nvect, T d)
bool isFrontFacing(const glm::vec3 &lookDirection) const
Test if the triangle would be front or backfacing from any point.
float getKnownIntersectionWithLine(const glm::vec3 &linePoint1, const glm::vec3 &linePoint2) const
Get percentage of line between two points where an intersection with this plane happens.
bool getIntersectionWithLine(const glm::vec3 &linePoint, const glm::vec3 &lineVect, glm::vec3 &outIntersection) const
Get an intersection with a 3d line.
EIntersectionRelation3D
Enumeration for intersection relations of 3d objects.
glm::vec3 getMemberPoint() const
Gets a member point of the plane.
bool equals(const T a, const T b, const T tolerance=roundingError< T >())
returns if a equals b, taking possible rounding errors into account
void recalculateD(const glm::vec3 &MPoint)
Recalculates the distance from origin by applying a new member point to the plane.
EIntersectionRelation3D classifyPointRelation(const glm::vec3 &point) const
Classifies the relation of a point to this plane.
plane3d< std::int32_t > plane3di
Typedef for an integer 3d plane.
bool isBetweenPoints(const glm::vec3 &point, const glm::vec3 &begin, const glm::vec3 &end)
const float ROUNDING_ERROR_float
T getDistanceTo(const glm::vec3 &point) const
Get the distance to a point.
void setPlane(const glm::vec3 &point, const glm::vec3 &nvector)
bool getIntersectionWithPlane(const plane3d< T > &other, glm::vec3 &outLinePoint, glm::vec3 &outLineVect) const
Intersects this plane with another.
const double ROUNDING_ERROR_double
bool operator!=(const plane3d< T > &other) const
void setPlane(const glm::vec3 &point1, const glm::vec3 &point2, const glm::vec3 &point3)
#define F32_LOWER_EQUAL_0(n)
bool getIntersectionWithLimitedLine(const glm::vec3 &linePoint1, const glm::vec3 &linePoint2, glm::vec3 &outIntersection) const
Get an intersection with a 3d line, limited between two 3d points.
plane3d< float > plane3df
Typedef for a float 3d plane.
bool operator==(const plane3d< T > &other) const
bool existsIntersection(const plane3d< T > &other) const
Tests if there is an intersection with the other plane.
bool getIntersectionWithPlanes(const plane3d< T > &o1, const plane3d< T > &o2, glm::vec3 &outPoint) const
Get the intersection point with two other planes if there is one.
plane3d(const glm::vec3 &point1, const glm::vec3 &point2, const glm::vec3 &point3)
plane3d(const glm::vec3 &normal, const T d)
glm::vec3 Normal
Normal vector of the plane.