Back to class index
Triangle[Class Summary]
a
b
c
ctor (+1 overload)
Translate(offset)
Transform(transform) (+3 overloads)
BarycentricUVW(point)[const]
BarycentricUV(point)[const]
Point(uvw)[const] (+3 overloads)
Centroid()[const]
CenterPoint()[const]
Area()[const]
Perimeter()[const]
VertexArrayPtr() (+1 overload)
Vertex(i)[const]
CornerPoint(i)[const]
Edge(i)[const]
PlaneCCW()[const]
PlaneCW()[const]
NormalCCW()[const]
NormalCW()[const]
UnnormalizedNormalCCW()[const]
UnnormalizedNormalCW()[const]
AnyPointFast()[const]
ExtremePoint(direction)[const] (+1 overload)
ToPolygon()[const]
ToPolyhedron()[const]
BoundingAABB()[const]
IsFinite()[const]
IsDegenerate(epsilon)[const]
Contains(...)[const] (+2 overloads)
Distance(point)[const] (+2 overloads)
DistanceSq(point)[const]
Intersects(...)[const] (+12 overloads)
ProjectToAxis(axis,dMin,dMax)[const]
UniqueFaceNormals(out)[const]
UniqueEdgeDirections(out)[const]
ClosestPoint(point)[const] (+3 overloads)
ClosestPointToTriangleEdge(...)[const] (+1 overload)
RandomPointInside(rng)[const]
RandomVertex(rng)[const]
RandomPointOnEdge(rng)[const]
ToString()[const]
SerializeToString()[const]
SerializeToCodeString()[const]
Equals(rhs,epsilon)[const]
BitEquals(other)[const]
NumFaces()[static]
NumEdges()[static]
NumVertices()[static]
BarycentricInsideTriangle(uvw)[static]
Area2D(p1,p2,p3)[static]
SignedArea(point,a,b,c)[static]
IsDegenerate(p1,p2,p3,epsilon)[static]
IntersectLineTri(...)[static]
FromString(str,outEndStr)[static] (+1 overload)

Triangle::ClosestPoint

Syntax

float4 Triangle::ClosestPoint(const float4 &point) const; [57 lines of code]
float4 Triangle::ClosestPoint(const LineSegment &lineSegment, float4 *otherPt=0) const; [43 lines of code]
float4 Triangle::ClosestPoint(const Line &line, float4 *otherPt=0) const; [17 lines of code]
float4 Triangle::ClosestPoint(const Triangle &triangle, float4 *otherPt=0) const; [47 lines of code]

Computes the closest point on this triangle to the given object.

If the other object intersects this triangle, this function will return an arbitrary point inside the region of intersection.

The code for Triangle-float3 test is from Christer Ericson's Real-Time Collision Detection, pp. 141-142.

The code for computing the closest point pair on two Triangles is based on pseudo-code from Christer Ericson's Real-Time Collision Detection, pp. 155-156.

Parameters

float4 *otherPt [out]If specified, receives the closest point on the other object to this triangle. This pointer may be null.

See Also

Contains(), Distance(), Intersects(), ClosestPointToTriangleEdge().

Work in progress:

Todo: in float4 Triangle::ClosestPoint(const LineSegment &lineSegment, float4 *otherPt=0) const:
Optimize.
Todo: in float4 Triangle::ClosestPoint(const Line &line, float4 *otherPt=0) const:
Add ClosestPoint(Ray/Plane/Polygon/Circle/Disk/AABB/OBB/Sphere/Capsule/Frustum/Polyhedron).
Todo: in float4 Triangle::ClosestPoint(const Line &line, float4 *otherPt=0) const:
Optimize this function.