Distance between cone and point How can I find minimum distance between cone and a point ?
Cone properties :
position - $(0,0,z)$
radius - $R$
height -  $h$
Point properties:
position - $(0,0,z_1)$

Similar to @KarolisJuodelė, we assume a right cone. and work in a 2D coordinate system (r,h).
Let the opening angle be $2\phi$, with $\phi = tan^{-1} ( \frac{r}{h} )$.
For any point X = ($X_r,X_h$), The answer is:
$X_rcos\phi-(h-X_h)sin\phi$
Derivation:
We would like to know the distance along the normal a point is from the surface of a right cone oriented along the z-axis.  See figure 1.

Here, d is the distance along the normal to point X.  W is the intersection of the normal with the Z axis. h and r are the dimensions of the cone.  Intuitively, since the normal is orthogonal to the surface of the cone, we see that we can calculate $d = \Vert X - W \Vert - (h-W_h)sin\phi$.
Working in 2D (r,h) with the cone aligned on the h axis for simplicity.


*

*$d = \Vert X - W \Vert - (h-W_h)sin\phi$

*$d = \sqrt{(X_r-W_r)^2+(X_h-W_h)^2} - (h-W_h)sin\phi$


W is along the h axis, so $W_r=0$.  Also, we can see that the slope of the normal is $\frac{r}{h}=tan\phi$, because the slope is orthogonal to the surface.  We rewrite $W_h$ in terms of X.  $W_h = X_h-X_r tan\phi$.  We continue, substituting for W.


*$d = \sqrt{X_r^2+(X_h-X_h+X_rtan\phi)^2} - (h-X_h+X_rtan\phi)sin\phi$

*$d = \sqrt{X_r^2(1+tan^2\phi)} - (h-X_h+X_rtan\phi)sin\phi$

*$d = X_rsec\phi-(h-x_h)sin\phi-X_r(\frac{sin^2\phi}{cos\phi})$

*$d = X_r(\frac{1-sin^2\phi}{cos\phi})-(h-x_h)sin\phi$

*$d = X_rcos\phi-(h-X_h)sin\phi$


This can be intuitively seen using similar triangles as shown in figure 2.

