3es
0.7
|
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]) |
Geometry functions based around triangles.
Intersect a triangle with an axis aligned box.
tri | The triangle vertices. |
aabb | The axis aligned box. Index zero is the minimum extents, index one the maximum. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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:
So long as dir
is normalised, the hitTime
represents the distance long the ray at which intersection occurs.
[out] | hitTime | Represents the intersection 'time'. Must not be null. |
v0 | A triangle vertex. | |
v1 | A triangle vertex. | |
v2 | A triangle vertex. | |
origin | The ray origin. | |
dir | The ray direction. Need not be normalised, but is best to be. | |
epsilon | Intersection error tolerance. |
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.
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.
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.
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.
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.
tri | Triangle vertices. |
epsilon | Error tolerance. |
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.
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.
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.
Check if a point lies inside a triangle, assuming they are on the same plane.
Results are undefined for degenerate triangles.
point | The point to test. Assumed to be on the triangle plane. |
tri | The triangle vertices. |
point
lies inside the triangle. 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.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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.
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.
point | The point of interest. |
tri | The triangle vertices. |
tri
closest to point
. 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.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Calculate the triangle normal.
Results are undefined for degenerate triangles.
tri | Triangle vertices. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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.
tri | Triangle vertices. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.