3es  0.7
tes::trigeom Namespace Reference

Geometry functions based around triangles. More...

Functions

Vector3f normal (const Vector3f &v0, const Vector3f &v1, const Vector3f &v2)
 
Vector3f normal (const Vector3f tri[3])
 Calculate the triangle normal. More...
 
Vector4f plane (const Vector3f &v0, const Vector3f &v1, const Vector3f &v2)
 
Vector4f plane (const Vector3f tri[3])
 Calculate a plane representation for the given triangle. More...
 
bool isDegenerate (const Vector3f &v0, const Vector3f &v1, const Vector3f &v2, float epsilon=1e-6f)
 
bool isDegenerate (const Vector3f tri[3], float epsilon=1e-6f)
 Check for a degenerate triangle This checks the magnitude of the cross product of the edges to be greater than epsilon for non-degenerate triangles. More...
 
bool isPointInside (const Vector3f &point, const Vector3f &v0, const Vector3f &v1, const Vector3f &v2)
 
bool isPointInside (const Vector3f &point, const Vector3f tri[3])
 Check if a point lies inside a triangle, assuming they are on the same plane. More...
 
Vector3f nearestPoint (const Vector3f &point, const Vector3f &v0, const Vector3f &v1, const Vector3f &v2)
 
Vector3f nearestPoint (const Vector3f &point, const Vector3f tri[3])
 Find a point on or within tri closest to point. More...
 
bool intersectRay (float *hitTime, const Vector3f &v0, const Vector3f &v1, const Vector3f &v2, const Vector3f &origin, const Vector3f &dir, const float epsilon=1e-6f)
 Performs a ray/triangle intersection test. More...
 
bool intersectTriangles (const Vector3f &a0, const Vector3f &a1, const Vector3f &a2, const Vector3f &b0, const Vector3f &b1, const Vector3f &b2, const float epsilon=1e-6f)
 Triangle intersection test. More...
 
bool intersectAABB (const Vector3f tri[3], const Vector3f aabb[2])
 Intersect a triangle with an axis aligned box. More...
 
Vector3d normal (const Vector3d &v0, const Vector3d &v1, const Vector3d &v2)
 
Vector3d normal (const Vector3d tri[3])
 
Vector4d plane (const Vector3d &v0, const Vector3d &v1, const Vector3d &v2)
 
Vector4d plane (const Vector3d tri[3])
 
bool isDegenerate (const Vector3d &v0, const Vector3d &v1, const Vector3d &v2, double epsilon=1e-6)
 
bool isDegenerate (const Vector3d tri[3], double epsilon=1e-6)
 
bool isPointInside (const Vector3d &point, const Vector3d &v0, const Vector3d &v1, const Vector3d &v2)
 
bool isPointInside (const Vector3d &point, const Vector3d tri[3])
 
Vector3d nearestPoint (const Vector3d &point, const Vector3d &v0, const Vector3d &v1, const Vector3d &v2)
 
Vector3d nearestPoint (const Vector3d &point, const Vector3d tri[3])
 
bool intersectRay (double *hitTime, const Vector3d &v0, const Vector3d &v1, const Vector3d &v2, const Vector3d &origin, const Vector3d &dir, const double epsilon=1e-6)
 
bool intersectTriangles (const Vector3d &a0, const Vector3d &a1, const Vector3d &a2, const Vector3d &b0, const Vector3d &b1, const Vector3d &b2, const double epsilon=1e-6)
 
bool intersectAABB (const Vector3d tri[3], const Vector3d aabb[2])
 

Detailed Description

Geometry functions based around triangles.

Function Documentation

◆ intersectAABB() [1/2]

bool tes::trigeom::intersectAABB ( const Vector3f  tri[3],
const Vector3f  aabb[2] 
)

Intersect a triangle with an axis aligned box.

Parameters
triThe triangle vertices.
aabbThe axis aligned box. Index zero is the minimum extents, index one the maximum.
Returns
True if the triangle overlaps, lies inside or contains the box.

◆ intersectAABB() [2/2]

bool tes::trigeom::intersectAABB ( const Vector3d  tri[3],
const Vector3d  aabb[2] 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ intersectRay() [1/2]

bool tes::trigeom::intersectRay ( float *  hitTime,
const Vector3f v0,
const Vector3f v1,
const Vector3f v2,
const Vector3f origin,
const Vector3f dir,
const float  epsilon = 1e-6f 
)

Performs a ray/triangle intersection test.

When an intersection occurs, the hitTime is set to represent the 'time' of intersection along the ray dir. This is always positive and intersections backwards along the ray are ignored. The location of the intersection can be calculated as:

Vector3f p = origin + hitTime * dir;

So long as dir is normalised, the hitTime represents the distance long the ray at which intersection occurs.

Parameters
[out]hitTimeRepresents the intersection 'time'. Must not be null.
v0A triangle vertex.
v1A triangle vertex.
v2A triangle vertex.
originThe ray origin.
dirThe ray direction. Need not be normalised, but is best to be.
epsilonIntersection error tolerance.

◆ intersectRay() [2/2]

bool tes::trigeom::intersectRay ( double *  hitTime,
const Vector3d v0,
const Vector3d v1,
const Vector3d v2,
const Vector3d origin,
const Vector3d dir,
const double  epsilon = 1e-6 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ intersectTriangles() [1/2]

bool tes::trigeom::intersectTriangles ( const Vector3f a0,
const Vector3f a1,
const Vector3f a2,
const Vector3f b0,
const Vector3f b1,
const Vector3f b2,
const float  epsilon = 1e-6f 
)

Triangle intersection test.

As a special case, the triangles are not considered intersecting when they exactly touch (equal vertices) and epsilon is zero.

◆ intersectTriangles() [2/2]

bool tes::trigeom::intersectTriangles ( const Vector3d a0,
const Vector3d a1,
const Vector3d a2,
const Vector3d b0,
const Vector3d b1,
const Vector3d b2,
const double  epsilon = 1e-6 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ isDegenerate() [1/4]

bool tes::trigeom::isDegenerate ( const Vector3f v0,
const Vector3f v1,
const Vector3f v2,
float  epsilon = 1e-6f 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ isDegenerate() [2/4]

bool tes::trigeom::isDegenerate ( const Vector3f  tri[3],
float  epsilon = 1e-6f 
)

Check for a degenerate triangle This checks the magnitude of the cross product of the edges to be greater than epsilon for non-degenerate triangles.

Parameters
triTriangle vertices.
epsilonError tolerance.
Returns
True if the triangle is degenerate.

◆ isDegenerate() [3/4]

bool tes::trigeom::isDegenerate ( const Vector3d v0,
const Vector3d v1,
const Vector3d v2,
double  epsilon = 1e-6 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ isDegenerate() [4/4]

bool tes::trigeom::isDegenerate ( const Vector3d  tri[3],
double  epsilon = 1e-6 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ isPointInside() [1/4]

bool tes::trigeom::isPointInside ( const Vector3f point,
const Vector3f v0,
const Vector3f v1,
const Vector3f v2 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ isPointInside() [2/4]

bool tes::trigeom::isPointInside ( const Vector3f point,
const Vector3f  tri[3] 
)

Check if a point lies inside a triangle, assuming they are on the same plane.

Results are undefined for degenerate triangles.

Parameters
pointThe point to test. Assumed to be on the triangle plane.
triThe triangle vertices.
Returns
True if point lies inside the triangle.

◆ isPointInside() [3/4]

bool tes::trigeom::isPointInside ( const Vector3d point,
const Vector3d v0,
const Vector3d v1,
const Vector3d v2 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ isPointInside() [4/4]

bool tes::trigeom::isPointInside ( const Vector3d point,
const Vector3d  tri[3] 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ nearestPoint() [1/4]

Vector3f tes::trigeom::nearestPoint ( const Vector3f point,
const Vector3f v0,
const Vector3f v1,
const Vector3f v2 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ nearestPoint() [2/4]

Vector3f tes::trigeom::nearestPoint ( const Vector3f point,
const Vector3f  tri[3] 
)

Find a point on or within tri closest to point.

The point need not be on the same plane as it is first projected onto that plane.. Results are undefined for degenerate triangles.

Parameters
pointThe point of interest.
triThe triangle vertices.
Returns
The point on or within tri closest to point.

◆ nearestPoint() [3/4]

Vector3d tes::trigeom::nearestPoint ( const Vector3d point,
const Vector3d v0,
const Vector3d v1,
const Vector3d v2 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ nearestPoint() [4/4]

Vector3d tes::trigeom::nearestPoint ( const Vector3d point,
const Vector3d  tri[3] 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ normal() [1/4]

Vector3f tes::trigeom::normal ( const Vector3f v0,
const Vector3f v1,
const Vector3f v2 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ normal() [2/4]

Vector3f tes::trigeom::normal ( const Vector3f  tri[3])

Calculate the triangle normal.

Results are undefined for degenerate triangles.

Parameters
triTriangle vertices.
Returns
The triangle normal.

◆ normal() [3/4]

Vector3d tes::trigeom::normal ( const Vector3d v0,
const Vector3d v1,
const Vector3d v2 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ normal() [4/4]

Vector3d tes::trigeom::normal ( const Vector3d  tri[3])

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ plane() [1/4]

Vector4f tes::trigeom::plane ( const Vector3f v0,
const Vector3f v1,
const Vector3f v2 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ plane() [2/4]

Vector4f tes::trigeom::plane ( const Vector3f  tri[3])

Calculate a plane representation for the given triangle.

This calculates the triangle plane in the resulting XYZ coordinates, and a plane distance value in W.

Results are undefined for degenerate triangles.

Parameters
triTriangle vertices.
Returns
A representation of the triangle plane.

◆ plane() [3/4]

Vector4d tes::trigeom::plane ( const Vector3d v0,
const Vector3d v1,
const Vector3d v2 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ plane() [4/4]

Vector4d tes::trigeom::plane ( const Vector3d  tri[3])

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.