Click here to Skip to main content
11,920,641 members (55,115 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ C++/CLI C VC10.0

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.

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: bad
Please Sign up or sign in to vote.

Solution 1

You can find the required math and a simple implementation right here:[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 6

this might be useful for you:[^]
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)

  Print Answers RSS
0 OriginalGriff 415
1 phil.o 170
2 Dave Kreskowiak 155
3 KrunalRohit 134
4 F-ES Sitecore 130
0 OriginalGriff 6,778
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,203
3 George Jonsson 2,815
4 Suvendu Shekhar Giri 2,181

Advertise | Privacy | Mobile
Web02 | 2.8.151120.1 | Last Updated 7 Aug 2013
Copyright © CodeProject, 1999-2015
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