简体   繁体   中英

Find the distance between a point to a triangle in 3D

As far as I know the method to find distance between 3D point to triangle is to check if the point is lie inside triangle's plane so the distance will be closest distance to triangle's plane, otherwise if the point lie outside of the triangle then the distance will be closest distance to one of triangle's edge.

Only one question for the method above is I don't know how to detect whether a point is lie inside triangle's plane.

Or is there any other better method to find the distance?

If you have some code examples will be more helpful.

You can follow this quite simple way: as an input you've got the 3 vertices A, B and C of the triangle and a point P. Get the normal vector of the plane n:

n = (A - B) x (C - B)

Then to check if P belongs to the plane, you simply check if the vector

m = (P - B) x (P - C)

is proportional to n.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM