5 #ifndef __IRR_TRIANGLE_3D_H_INCLUDED__ 6 #define __IRR_TRIANGLE_3D_H_INCLUDED__ 38 return !(*
this==other);
79 return d1 < d3 ? rab : rca;
81 return d2 < d3 ? rbc : rca;
95 return (isOnSameSide(pf64, af64, bf64, cf64) &&
96 isOnSameSide(pf64, bf64, af64, cf64) &&
97 isOnSameSide(pf64, cf64, af64, bf64));
114 const f64 dotAA =
a.dotProduct(
a);
115 const f64 dotAB =
a.dotProduct(
b);
116 const f64 dotAC =
a.dotProduct(
c);
117 const f64 dotBB =
b.dotProduct(
b);
118 const f64 dotBC =
b.dotProduct(
c);
121 const f64 invDenom = 1/(dotAA * dotBB - dotAB * dotAB);
122 const f64 u = (dotBB * dotAC - dotAB * dotBC) * invDenom;
123 const f64 v = (dotAA * dotBC - dotAB * dotAC ) * invDenom;
186 f64 d = trianglef64.
pointA.dotProduct(normalf64);
188 outIntersectionf64 = linePointf64 + (lineVectf64 *
t);
190 outIntersection.
X = (T)outIntersectionf64.
X;
191 outIntersection.
Y = (T)outIntersectionf64.
Y;
192 outIntersection.
Z = (T)outIntersectionf64.
Z;
213 const f32 d = (
f32)
n.dotProduct(lookDirection);
264 return (
res >= 0.0
f);
vector3d< T > crossProduct(const vector3d< T > &p) const
Calculates the cross product with another vector.
vector3d< T > MaxEdge
The far edge.
T Y
Y coordinate of the vector.
bool iszero(const f64 a, const f64 tolerance=ROUNDING_ERROR_f64)
returns if a equals zero, taking rounding errors into account
bool isTotalInsideBox(const aabbox3d< T > &box) const
Determines if the triangle is totally inside a bounding box.
vector3d< T > getClosestPoint(const vector3d< T > &point) const
Get the closest point on this line to a point.
float f32
32 bit floating point variable.
triangle3d()
Constructor for an all 0 triangle.
bool getIntersectionOfPlaneWithLine(const vector3d< T > &linePoint, const vector3d< T > &lineVect, vector3d< T > &outIntersection) const
Calculates the intersection between a 3d line and the plane the triangle is on.
3d triangle template class for doing collision detection and other things.
T X
X coordinate of the vector.
Everything in the Irrlicht Engine can be found in this namespace.
bool isPointInside(const vector3d< T > &p) const
Determines if a point is within this box.
triangle3d< f32 > triangle3df
Typedef for a f32 3d triangle.
3d vector template class with lots of operators and methods.
bool getIntersectionWithLine(const vector3d< T > &linePoint, const vector3d< T > &lineVect, vector3d< T > &outIntersection) const
Get an intersection with a 3d line.
GLfloat GLfloat GLfloat v2
3D line between two points with intersection methods.
double f64
64 bit floating point variable.
bool isFrontFacing(const vector3d< T > &lookDirection) const
Test if the triangle would be front or backfacing from any point.
vector3d< T > pointA
the three points of the triangle
vector3d< T > getVector() const
Get vector of line.
bool isTotalOutsideBox(const aabbox3d< T > &box) const
Determines if the triangle is totally outside a bounding box.
void set(const core::vector3d< T > &a, const core::vector3d< T > &b, const core::vector3d< T > &c)
sets the triangle's points
const f32 ROUNDING_ERROR_f32
GLfloat GLfloat GLfloat GLfloat v3
plane3d< T > getPlane() const
Get the plane of this triangle.
vector3d< T > end
End point of line.
triangle3d(const vector3d< T > &v1, const vector3d< T > &v2, const vector3d< T > &v3)
Constructor for triangle with given three vertices.
bool operator!=(const triangle3d< T > &other) const
Inequality operator.
Template plane class with some intersection testing methods.
T getArea() const
Get the area of the triangle.
triangle3d< s32 > triangle3di
Typedef for an integer 3d triangle.
bool isPointInside(const vector3d< T > &p) const
Check if a point is inside the triangle (border-points count also as inside)
vector3d< T > & normalize()
Normalizes the vector.
bool operator==(const triangle3d< T > &other) const
Equality operator.
vector3d< T > MinEdge
The near edge.
bool isPointInsideFast(const vector3d< T > &p) const
Check if a point is inside the triangle (border-points count also as inside)
vector3d< T > start
Start point of line.
T dotProduct(const vector3d< T > &other) const
Get the dot product with another vector.
core::vector3d< T > closestPointOnTriangle(const core::vector3d< T > &p) const
Get the closest point on a triangle to a point on the same plane.
GLboolean GLboolean GLboolean b
T Z
Z coordinate of the vector.
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.
T getDistanceFrom(const vector3d< T > &other) const
Get distance from another point.
Axis aligned bounding box in 3d dimensional space.
GLboolean GLboolean GLboolean GLboolean a
bool getIntersectionWithLimitedLine(const line3d< T > &line, vector3d< T > &outIntersection) const
Get an intersection with a 3d line.
vector3d< T > getNormal() const
Get the normal of the triangle.
#define F32_LOWER_EQUAL_0(n)