12,063,645 members (56,844 online)
Rate this:
See more:
Hello

Im looking for a C/C++ code for a computing the minimum distance between a Point and Triangle in 3D. Please anyone can help me.

Thanks
Bojan
Posted 11-Jul-10 8:53am
Sandeep Mewara 11-Jul-10 14:01pm

What have you tried so far? Any effort made till now?
Member 4644164 12-Jul-10 7:04am

Yea I have some algorithm but still not implemented in a C/C++ code.

First algorithm:
1) Find intersection of a line normal to a virtual side of the triangle.
2) Determine if intersection point is physically on the side. If not use the nearestend point.
3) Repeat for each of the sides.

Second algorithm:

If the point is inside the triangle when projected onto the plane of the triangle then the distance will be the distance from the point to the plane of the triangle, and if it's not then the distance will be the shortest distance between the point and any of the line segments of the triangle. But I can not find all those operations in code in one place, but maybe point projected onto plane, point in triangle, distance from point to plane, and distance from edge to point pretty easily separate.

Rate this:

## Solution 1

You can find the required math and a simple implementation right here:
http://www.geometrictools.com/Documentation/DistancePoint3Triangle3.pdf[^]
Rate this:

## Solution 6

this might be useful for you:

www-compsci.swan.ac.uk/~csmark/PDFS/dist.pdf[^]
CHill60 7-Aug-13 10:00am

Top Experts
Last 24hrsThis month
 CHill60 220 CPallini 215 d@nish 200 ppolymorphe 99 Chris Maunder 85
 Dave Kreskowiak 1,827 Richard MacCutchan 1,250 d@nish 980 OriginalGriff 844 CPallini 740