# closest point to a polyhedral cone

I have a 6-sided equilateral polyhedral cone in $R^3$ defined by a symmetric set of equations:

$C=\{(X_1,X_2,X_3)\ |\ K X_i\leq X_j \forall i,j\in\{1,2,3\}\}$

Given an point $P=(P_1,P_2,P_3)$, I would like to know what is the closest point on the cone to $P$.

I will need to implement this as an algorithm, so the more elegant a solution the better.

You can minimize the squared distance to $X$ subject to the six linear constraints. this is a strictly convex quadratic program.

If calling a general-purpose convex QP-solver (such as my MINQ in Matlab) is too slow, you can work out the Kuhn-Tucker optimality conditions (here necessary and sufficient), and make a case analysis. Because of symmetry you only need to distinguish three cases: Solution at the vertex, on a ray, and on a face. Then you can program it, taking also account of the need to permute the points, giving additional cases (but just permuted solution formulas).