Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++/CLI C VC10.0
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
Comments
Sandeep Mewara at 11-Jul-10 14:01pm
   
What have you tried so far? Any effort made till now?
Member 4644164 at 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: bad
good
Please Sign up or sign in to vote.

Solution 1

You can find the required math and a simple implementation right here:
http://www.geometrictools.com/Documentation/DistancePoint3Triangle3.pdf[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

this might be useful for you:
 
www-compsci.swan.ac.uk/~csmark/PDFS/dist.pdf[^]
  Permalink  
Comments
CHill60 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 485
1 BillWoodruff 330
2 OriginalGriff 310
3 Shweta N Mishra 244
4 Mathew Soji 225
0 OriginalGriff 6,153
1 Sergey Alexandrovich Kryukov 5,638
2 DamithSL 4,958
3 Manas Bhardwaj 4,539
4 Maciej Los 3,710


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 7 Aug 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100