Given the vertices of a solid face, compute the distance of a point from the face

37 Views Asked by At

I am writing a program where I need to compute the ordinary distance of a point from a face of a solid (imagine, for instance, a point inside a cube).

I have all the vertices of the face (x,y,z) [or (x,y,z,w) in homogeneous coordinates]. I was wondering if there is some computationally comfortable/efficient way to compute the euclidean distance of a given point from the face.

I am aware of the formula of "distance from a point to a plane", but I would like something more straightforward, possibly not based on the plane coefficients, which can provide the distance only using the coordinates of the point and of 3 of the face vertices. Can you point me in the right direction?

1

There are 1 best solutions below

7
On BEST ANSWER

Using three vertices of the face, compute the unit normal vector to the face. This can be computed as follows: If $A, B, C$ are three vertices then

$n = \dfrac{ v }{|v|} $

where $v = (B - A) \times (C - A) $

The distance between a point $P$ and the face is simply $ | (P - A) \cdot n | $. (That is, the absolute value of the dot product of the vector $(P - A)$ with the normal vector $n$).