TITLE: Find Point on Polyhedron Nearest Given Point
QUESTION [0 upvotes]: Given the 8 vertices (Y, R, M, B, C, G, K, W) of a polyhedron with 12 faces, 18 edges, and 8 vertices and another point somewhere in 3D space (P) find whether the point is within, on, or outside the polyhedron; if it is outside find the nearest point on the polyhedron to the given point (Q).
The polyhedron can be normal or irregularly shaped, and no vertex will ever be placed in a manner where the shape will fold in on itself. Here's some images where I modeled this in a 3D program to show what I mean:

I am quite a bit rusty (or entirely ignorant) when it comes to math of this level, but I've been experimenting with it some lately due to dabbling deeper in color theory (which is what this really is). My first attempts at solving this were to get plane equations for each of the faces, line intersects for those planes for each of the edges, and of course I already have the vertices. But, the planes and lines are infinite and the faces and edges are finite. When getting the point on the plane closest to the given point it can be completely off it. Am I on the right track here and not knowing it or can someone point me in the correct direction as to how to solve this?
So for an example:
Vertices of the polyhedron above:
Y(205, 193, 57)
R(201, 44, 21)
M(146, 115, 129)
B(111, 113, 131)
C(113, 130, 130)
G(75, 144, 99)
K(25, 25, 29)
W(242, 240, 238)
Given point (P):
Anything between 0 and 255 for x, y, and z.

REPLY [1 votes]: You can use polyhedral geometry to simplify the calculations somewhat and make them look more elegant, but basically the straightforward way to solve this is to first project the point onto each plane passing through a face, and if the projection point is contained in the face (point in polygon test) and the point is in the positive direction of the normal vector for the face then that is the answer. Otherwise, project the point onto the line through each edge. If the projection point is contained in the edge then that is a candidate answer. The other candidate answer is the vertex which is closest to the point. The best candidate is the answer.
{"set_name": "stack_exchange", "score": 0, "question_id": 1134225}