Click here to Skip to main content
15,867,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Comments
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.

You can find the required math and a simple implementation right here:
http://www.geometrictools.com/Documentation/DistancePoint3Triangle3.pdf[^]
 
Share this answer
 
this might be useful for you:

www-compsci.swan.ac.uk/~csmark/PDFS/dist.pdf[^]
 
Share this answer
 
Comments
CHill60 7-Aug-13 10:00am    
FYI Answering questions that are 3 years old and already resolved, with a link that just links back to this question will attracct downvotes

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900