Click here to Skip to main content
13,090,541 members (49,030 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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 7: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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 7 Aug 2013
Copyright © CodeProject, 1999-2017
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